From 810c3162c83af7bf81b61a72b376906e3539cdaa Mon Sep 17 00:00:00 2001 From: HappyRespawnanchor <80967824+HappyRespawnanchor@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:59:51 +0800 Subject: [PATCH] AyamePlayerHandRenderer --- .../ayame/client/api/PlayerModelAPI.java | 4 +-- .../client/handler/ClientEventHandler.java | 1 + .../renderer/AyamePlayerHandRenderer.java | 33 +++++++++++++++++++ ...ayerRender.java => AyamePlayerRender.java} | 4 +-- .../client/ClientEntityRenderersMixin.java | 6 ++-- .../ayamemc/ayame/model/DefaultModels.java | 1 + .../main/resources/architectury.common.json | 3 ++ 7 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerHandRenderer.java rename common/src/main/java/org/ayamemc/ayame/client/renderer/{GeoPlayerRender.java => AyamePlayerRender.java} (96%) diff --git a/common/src/main/java/org/ayamemc/ayame/client/api/PlayerModelAPI.java b/common/src/main/java/org/ayamemc/ayame/client/api/PlayerModelAPI.java index d533425..a87df1b 100644 --- a/common/src/main/java/org/ayamemc/ayame/client/api/PlayerModelAPI.java +++ b/common/src/main/java/org/ayamemc/ayame/client/api/PlayerModelAPI.java @@ -21,7 +21,7 @@ package org.ayamemc.ayame.client.api; import net.minecraft.world.entity.player.Player; -import org.ayamemc.ayame.client.renderer.GeoPlayerRender; +import org.ayamemc.ayame.client.renderer.AyamePlayerRender; import org.ayamemc.ayame.model.AyameModelCache; import org.ayamemc.ayame.model.ModelType; import org.ayamemc.ayame.util.FileUtil; @@ -41,7 +41,7 @@ public class PlayerModelAPI { * @param model 模型 */ public static void switchModel(Player player, ModelType model) { - GeoPlayerRender.GeoPlayerModel.switchModel(player, model); + AyamePlayerRender.GeoPlayerModel.switchModel(player, model); cacheModel(player, model); } diff --git a/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java b/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java index 0324668..3d2e91f 100644 --- a/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java +++ b/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java @@ -27,6 +27,7 @@ import net.minecraft.world.item.ItemStack; import org.ayamemc.ayame.client.gui.screen.AyameScreen; import org.ayamemc.ayame.client.gui.screen.ModelSelectMenuScreen; +import software.bernie.geckolib.renderer.GeoItemRenderer; public class ClientEventHandler { public static final int TOOLTIP_BACKGROUND_COLOR = 0xCC_5f5f5f; diff --git a/common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerHandRenderer.java b/common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerHandRenderer.java new file mode 100644 index 0000000..2022e41 --- /dev/null +++ b/common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerHandRenderer.java @@ -0,0 +1,33 @@ +/* + * Custom player model mod. Powered by GeckoLib. + * Copyright (C) 2024 CrystalNeko, HappyRespawnanchor, pertaz(Icon Designer) + * + * This file is part of Ayame. + * + * Ayame is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Ayame is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Ayame. If not, see . + */ + +package org.ayamemc.ayame.client.renderer; + +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.entity.layers.ItemInHandLayer; +import software.bernie.geckolib.animatable.GeoAnimatable; +import software.bernie.geckolib.model.GeoModel; +import software.bernie.geckolib.renderer.*; + +public class AyamePlayerHandRenderer extends GeoObjectRenderer { + public AyamePlayerHandRenderer(GeoModel model) { + super(model); + } +} diff --git a/common/src/main/java/org/ayamemc/ayame/client/renderer/GeoPlayerRender.java b/common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerRender.java similarity index 96% rename from common/src/main/java/org/ayamemc/ayame/client/renderer/GeoPlayerRender.java rename to common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerRender.java index 9d16f68..64b1735 100644 --- a/common/src/main/java/org/ayamemc/ayame/client/renderer/GeoPlayerRender.java +++ b/common/src/main/java/org/ayamemc/ayame/client/renderer/AyamePlayerRender.java @@ -37,10 +37,10 @@ import software.bernie.geckolib.renderer.GeoEntityRenderer; @Environment(EnvType.CLIENT) -public class GeoPlayerRender extends GeoEntityRenderer { +public class AyamePlayerRender extends GeoEntityRenderer { // TODO : 完善代码 & 添加API - public GeoPlayerRender(EntityRendererProvider.Context context) { + public AyamePlayerRender(EntityRendererProvider.Context context) { super(context, new GeoPlayerModel()); } diff --git a/common/src/main/java/org/ayamemc/ayame/mixin/client/ClientEntityRenderersMixin.java b/common/src/main/java/org/ayamemc/ayame/mixin/client/ClientEntityRenderersMixin.java index fe4c072..25f890b 100644 --- a/common/src/main/java/org/ayamemc/ayame/mixin/client/ClientEntityRenderersMixin.java +++ b/common/src/main/java/org/ayamemc/ayame/mixin/client/ClientEntityRenderersMixin.java @@ -28,7 +28,7 @@ import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.resources.PlayerSkin; import net.minecraft.world.entity.player.Player; -import org.ayamemc.ayame.client.renderer.GeoPlayerRender; +import org.ayamemc.ayame.client.renderer.AyamePlayerRender; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -46,8 +46,8 @@ public class ClientEntityRenderersMixin { @Inject(method = "createPlayerRenderers", at = @At("RETURN"), cancellable = true) private static void createPlayerRenderers(EntityRendererProvider.Context context, CallbackInfoReturnable>> cir) { - Map> m = new HashMap<>(Map.of(PlayerSkin.Model.WIDE, new GeoPlayerRender(context))); - m.put(PlayerSkin.Model.SLIM, new GeoPlayerRender(context)); + Map> m = new HashMap<>(Map.of(PlayerSkin.Model.WIDE, new AyamePlayerRender(context))); + m.put(PlayerSkin.Model.SLIM, new AyamePlayerRender(context)); cir.setReturnValue(ImmutableMap.copyOf(m)); } } \ No newline at end of file diff --git a/common/src/main/java/org/ayamemc/ayame/model/DefaultModels.java b/common/src/main/java/org/ayamemc/ayame/model/DefaultModels.java index bf19ca5..00f3a7c 100644 --- a/common/src/main/java/org/ayamemc/ayame/model/DefaultModels.java +++ b/common/src/main/java/org/ayamemc/ayame/model/DefaultModels.java @@ -20,6 +20,7 @@ package org.ayamemc.ayame.model; +import net.minecraft.world.entity.Entity; import org.ayamemc.ayame.Ayame; import org.ayamemc.ayame.model.resource.IModelResource; import org.ayamemc.ayame.model.resource.ModelContent; diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json index d763ec5..aea749d 100644 --- a/common/src/main/resources/architectury.common.json +++ b/common/src/main/resources/architectury.common.json @@ -4,6 +4,9 @@ "net/minecraft/class_1657": [ "software/bernie/geckolib/animatable/GeoEntity", "org/ayamemc/ayame/client/api/IAbleToSit" + ], + "net/minecraft/class_918": [ + "software/bernie/geckolib/animatable/GeoAnimatable" ] } } \ No newline at end of file