From 659260c9431f5c8ef02689ce9248c6d6be77cdce Mon Sep 17 00:00:00 2001 From: Raycoms Date: Fri, 23 Aug 2024 15:20:01 +0200 Subject: [PATCH] Fix mercenary rendering --- .../core/client/model/MercenaryModel.java | 48 +++++++++++++++++++ .../client/render/mobs/RenderMercenary.java | 8 ++-- .../core/event/ClientRegistryHandler.java | 4 ++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/minecolonies/core/client/model/MercenaryModel.java diff --git a/src/main/java/com/minecolonies/core/client/model/MercenaryModel.java b/src/main/java/com/minecolonies/core/client/model/MercenaryModel.java new file mode 100644 index 00000000000..12fc4ebd6e5 --- /dev/null +++ b/src/main/java/com/minecolonies/core/client/model/MercenaryModel.java @@ -0,0 +1,48 @@ +// Made with Blockbench 4.0.0-beta.0 +// Exported for Minecraft version 1.17 with Mojang mappings +// Paste this class into your mod and generate all required imports +package com.minecolonies.core.client.model; + +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.world.entity.PathfinderMob; + +public class MercenaryModel extends HumanoidModel +{ + public MercenaryModel(final ModelPart part) + { + super(part); + hat.visible = false; + } + + public static LayerDefinition createMesh() + { + MeshDefinition meshdefinition = HumanoidModel.createMesh(CubeDeformation.NONE, 0.0F); + PartDefinition partdefinition = meshdefinition.getRoot(); + + PartDefinition bipedHead = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)) + .texOffs(32, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, 0.0F, 0.0F)); + + PartDefinition shortBeard = bipedHead.addOrReplaceChild("shortBeard", CubeListBuilder.create().texOffs(24, 0).addBox(-3.5F, -24.0F, -4.0F, 7.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(24, 4).addBox(-3.5F, -23.0F, -4.0F, 7.0F, 3.0F, 1.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, 24.0F, 0.0F)); + + PartDefinition bipedBody = partdefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(16, 16).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(16, 32).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, new CubeDeformation(0.25F)), PartPose.offset(0.0F, 0.0F, 0.0F)); + + PartDefinition bipedRightArm = partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(40, 32).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.25F)), PartPose.offset(-5.0F, 2.0F, 0.0F)); + + PartDefinition bipedLeftArm = partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.25F)), PartPose.offset(5.0F, 2.0F, 0.0F)); + + PartDefinition bipedRightLeg = partdefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 16).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(0, 32).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.25F)), PartPose.offset(-1.9F, 12.0F, 0.0F)); + + PartDefinition bipedLeftLeg = partdefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(16, 48).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(0, 48).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.25F)), PartPose.offset(1.9F, 12.0F, 0.0F)); + + return LayerDefinition.create(meshdefinition, 128, 64); + } +} diff --git a/src/main/java/com/minecolonies/core/client/render/mobs/RenderMercenary.java b/src/main/java/com/minecolonies/core/client/render/mobs/RenderMercenary.java index e32e735cbe6..0d5bdf12522 100755 --- a/src/main/java/com/minecolonies/core/client/render/mobs/RenderMercenary.java +++ b/src/main/java/com/minecolonies/core/client/render/mobs/RenderMercenary.java @@ -1,19 +1,21 @@ package com.minecolonies.core.client.render.mobs; import com.minecolonies.api.util.constant.Constants; +import com.minecolonies.core.client.model.MercenaryModel; +import com.minecolonies.core.event.ClientRegistryHandler; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer; import net.minecraft.client.renderer.entity.layers.ItemInHandLayer; import net.minecraft.client.model.HumanoidModel; -import net.minecraft.world.entity.PathfinderMob; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.PathfinderMob; /** * Renderer for EntityMercenary. */ -public class RenderMercenary extends MobRenderer> +public class RenderMercenary extends MobRenderer { /** * Texture of the entity. @@ -27,7 +29,7 @@ public class RenderMercenary extends MobRenderer(context.bakeLayer(ModelLayers.PLAYER_INNER_ARMOR)), 0.5f); + super(context, new MercenaryModel(context.bakeLayer(ClientRegistryHandler.MERCENARY)), 0.5f); this.addLayer(new ItemInHandLayer<>(this, context.getItemInHandRenderer())); this.addLayer(new HumanoidArmorLayer<>(this, new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER_INNER_ARMOR)), new HumanoidModel<>(context.bakeLayer(ModelLayers.PLAYER_OUTER_ARMOR)), context.getModelManager())); diff --git a/src/main/java/com/minecolonies/core/event/ClientRegistryHandler.java b/src/main/java/com/minecolonies/core/event/ClientRegistryHandler.java index bfbb81f092b..d1be1713109 100644 --- a/src/main/java/com/minecolonies/core/event/ClientRegistryHandler.java +++ b/src/main/java/com/minecolonies/core/event/ClientRegistryHandler.java @@ -136,6 +136,8 @@ public class ClientRegistryHandler public static final ModelLayerLocation MALE_ALCHEMIST = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "male_alchemist"), "male_alchemist"); public static final ModelLayerLocation FEMALE_ALCHEMIST = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "female_alchemist"), "female_alchemist"); + public static final ModelLayerLocation MERCENARY = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "mercenary"), "mercenary"); + public static final ModelLayerLocation MUMMY = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "mummy"), "mummy"); public static final ModelLayerLocation ARCHER_MUMMY = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "archer_mummy"), "archer_mummy"); public static final ModelLayerLocation PHARAO = new ModelLayerLocation(new ResourceLocation(Constants.MOD_ID, "pharao"), "pharao"); @@ -156,6 +158,8 @@ public class ClientRegistryHandler @SubscribeEvent public static void registerLayerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) { + event.registerLayerDefinition(MERCENARY, MercenaryModel::createMesh); + event.registerLayerDefinition(AMAZON, ModelAmazon::createMesh); event.registerLayerDefinition(AMAZON_CHIEF, ModelAmazonChief::createMesh); event.registerLayerDefinition(AMAZON_SPEARMAN, ModelAmazonSpearman::createMesh);