Posted April 13, 20223 yr I created the armor and implemented it this way, but the SetupAnim does not work. I think the problem is that it is not being called, but where and how can I call it? Is it correct to describe it in the execution of each tick? Model public class Test_ArmorModel<T extends LivingEntity> extends HumanoidModel<T> { public static ModelLayerLocation LAYER_LOCATION_TOP = new ModelLayerLocation(new ResourceLocation(TestWorldMod.MOD_ID, "Test_armor_top"), "main"); public static ModelLayerLocation LAYER_LOCATION_BOTTOM = new ModelLayerLocation(new ResourceLocation(TestWorldMod.MOD_ID, "Test_armor_bottom"), "main"); public Test_ArmorModel(ModelPart root) { super(root); } public static LayerDefinition createBodyLayer(CubeDeformation size) { MeshDefinition meshdefinition = HumanoidModel.createMesh(size,0.0F); PartDefinition partdefinition = meshdefinition.getRoot(); PartDefinition Head = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 16).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)) .texOffs(0, 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 moon2 = Head.addOrReplaceChild("moon2", CubeListBuilder.create().texOffs(4, 18).addBox(5.0F, -24.0F, -6.7F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(4, 18).addBox(4.0F, -24.5F, -6.7F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(4, 18).addBox(6.0F, -24.5F, -6.7F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 18).addBox(5.5F, -23.0F, -7.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 18).addBox(4.5F, -23.5F, -7.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 18).addBox(4.5F, -24.5F, -7.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 18).addBox(5.5F, -25.0F, -7.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-3.0F, 17.0F, 2.0F)); PartDefinition Body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 32).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) .texOffs(28, 28).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 RightArm = partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(56, 0).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) .texOffs(52, 44).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 LeftArm = partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(52, 28).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) .texOffs(0, 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 RightLeg = partdefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(36, 44).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) .texOffs(20, 44).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 LeftLeg = partdefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(44, 12).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)) .texOffs(32, 0).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 RightFeather2 =Body.addOrReplaceChild("LeftFeather", CubeListBuilder.create().texOffs(4, 2).mirror().addBox(-7.5665F, -16.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(4, 2).mirror().addBox(-8.5665F, -17.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 0).mirror().addBox(-11.5665F, -15.7195F, 0.0796F, 3.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 0).mirror().addBox(-17.5665F, -18.7195F, 0.0796F, 4.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 16).mirror().addBox(-15.5665F, -19.7195F, 0.0796F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 16).mirror().addBox(-15.5665F, -17.7195F, 0.0796F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 20).mirror().addBox(-6.5665F, -19.7195F, 0.0796F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 16).mirror().addBox(-14.5665F, -20.7195F, 0.0796F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(16, 60).mirror().addBox(-18.5665F, -21.7195F, 0.0796F, 11.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 18).mirror().addBox(-16.5665F, -22.7195F, 0.0796F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(32, 20).mirror().addBox(-13.5665F, -19.7195F, 0.0796F, 5.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 2).addBox(-6.5665F, -15.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.0F, 23.0F, 0.0F, 0.0F, 0.2618F, 0.0873F)); PartDefinition RightFeather = Body.addOrReplaceChild("RightFeather", CubeListBuilder.create().texOffs(4, 2).addBox(0.793F, -17.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(4, 2).addBox(1.793F, -18.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 0).addBox(2.793F, -16.2424F, 1.6266F, 3.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 0).addBox(7.793F, -19.2424F, 1.6266F, 4.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 16).addBox(7.793F, -20.2424F, 1.6266F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 16).addBox(7.793F, -18.2424F, 1.6266F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 20).addBox(-0.207F, -20.2424F, 1.6266F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 16).addBox(0.793F, -21.2424F, 1.6266F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(16, 60).addBox(1.793F, -22.2424F, 1.6266F, 11.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 18).addBox(3.793F, -23.2424F, 1.6266F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(32, 20).addBox(2.793F, -20.2424F, 1.6266F, 5.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 2).addBox(-0.207F, -16.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(4.0F, 23.0F, 0.0F, 0.0F, -0.2618F, -0.0873F)); return LayerDefinition.create(meshdefinition, 128, 128); } @Override public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { head.render(poseStack, buffer, packedLight, packedOverlay); body.render(poseStack, buffer, packedLight, packedOverlay); rightArm.render(poseStack, buffer, packedLight, packedOverlay); leftArm.render(poseStack, buffer, packedLight, packedOverlay); rightLeg.render(poseStack, buffer, packedLight, packedOverlay); leftLeg.render(poseStack, buffer, packedLight, packedOverlay); } @Override public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { if (entity instanceof ArmorStand) { super.setupAnim(entity, 0, 0, 0, 0, 0); } else { float ff = ageInTicks * (float)Math.PI * -0.1F; rightArm.copyFrom(super.rightArm); leftArm.copyFrom(super.leftArm); head.copyFrom(super.head); body.copyFrom(super.body); leftLeg.copyFrom(super.leftLeg); rightLeg.copyFrom(super.rightLeg); super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch); } } } Renderer public class ModEntityRenderers extends EntityRenderers { public static final Map<Item, HumanoidModel<LivingEntity>> armorModels = new HashMap<>(); @SubscribeEvent public static void registerLayerDefinition(EntityRenderersEvent.RegisterLayerDefinitions event) { event.registerLayerDefinition(LAYER_LOCATION_TOP, () ->Test_ArmorModel.createBodyLayer(new CubeDeformation(0.5F))); event.registerLayerDefinition(LAYER_LOCATION_BOTTOM, ()-> Test_ArmorModel.createBodyLayer(new CubeDeformation(0.25F))); } @SubscribeEvent public static void registerLayers(EntityRenderersEvent.AddLayers event) { EntityRendererProvider.Context context = new EntityRendererProvider.Context(Minecraft.getInstance().getEntityRenderDispatcher(),Minecraft.getInstance().getItemRenderer(), Minecraft.getInstance().getResourceManager(), Minecraft.getInstance().getEntityModels(), Minecraft.getInstance().font); Test_ArmorModel<LivingEntity> vTop = new Test_ArmorModel<>(context.bakeLayer(LAYER_LOCATION_TOP)); Test_ArmorModel<LivingEntity> vBot = new Test_ArmorModel<>(context.bakeLayer(LAYER_LOCATION_BOTTOM)); armorModels.put(ModItems.HELMET.get(), vTop); armorModels.put(ModItems.CHESTPLATE.get(), vTop); armorModels.put(ModItems.LEGGINGS.get(), vBot); armorModels.put(ModItems.BOOTS.get(), vTop); } } Edited April 18, 20223 yr by ocome
April 14, 20223 yr Author I have checked many mods and no one has created a similar system. Is it too difficult?
April 17, 20223 yr Hello, I face the same problem. What's the current solution to animate armors with custom Model (without using GeckoLib) ?
April 18, 20223 yr Author Thank you for answering. We were able to confirm the operation. However, I felt that this method did not do what I expected it to do (armor model + animate with elytra). To do this, would it be necessary to create a separate elytra render to display the entity when the armor is installed? It would be nice if the animation could be performed only on the "RightFeather"... Edited April 18, 20223 yr by ocome
April 18, 20223 yr Author Sorry for my bad English. We are currently creating the left and right wings and they are included in the "body" On 4/13/2022 at 1:48 PM, ocome said: PartDefinition RightFeather2 =Body.addOrReplaceChild("LeftFeather", CubeListBuilder.create().texOffs(4, 2).mirror().addBox(-7.5665F, -16.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(4, 2).mirror().addBox(-8.5665F, -17.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 0).mirror().addBox(-11.5665F, -15.7195F, 0.0796F, 3.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 0).mirror().addBox(-17.5665F, -18.7195F, 0.0796F, 4.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 16).mirror().addBox(-15.5665F, -19.7195F, 0.0796F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 16).mirror().addBox(-15.5665F, -17.7195F, 0.0796F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 20).mirror().addBox(-6.5665F, -19.7195F, 0.0796F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 16).mirror().addBox(-14.5665F, -20.7195F, 0.0796F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(16, 60).mirror().addBox(-18.5665F, -21.7195F, 0.0796F, 11.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(24, 18).mirror().addBox(-16.5665F, -22.7195F, 0.0796F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(32, 20).mirror().addBox(-13.5665F, -19.7195F, 0.0796F, 5.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false) .texOffs(0, 2).addBox(-6.5665F, -15.7195F, 0.0796F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.0F, 23.0F, 0.0F, 0.0F, 0.2618F, 0.0873F)); PartDefinition RightFeather = Body.addOrReplaceChild("RightFeather", CubeListBuilder.create().texOffs(4, 2).addBox(0.793F, -17.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(4, 2).addBox(1.793F, -18.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 0).addBox(2.793F, -16.2424F, 1.6266F, 3.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 0).addBox(7.793F, -19.2424F, 1.6266F, 4.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 16).addBox(7.793F, -20.2424F, 1.6266F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 16).addBox(7.793F, -18.2424F, 1.6266F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 20).addBox(-0.207F, -20.2424F, 1.6266F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 16).addBox(0.793F, -21.2424F, 1.6266F, 8.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(16, 60).addBox(1.793F, -22.2424F, 1.6266F, 11.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(24, 18).addBox(3.793F, -23.2424F, 1.6266F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(32, 20).addBox(2.793F, -20.2424F, 1.6266F, 5.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)) .texOffs(0, 2).addBox(-0.207F, -16.2424F, 1.6266F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(4.0F, 23.0F, 0.0F, 0.0F, -0.2618F, -0.0873F)); This causes the "rightfether","leftfether" move, but of course the body moves with it. public HumanoidModel<?> getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default) { HumanoidModel armorModel = ModEntityRenderers.armorModels.get(itemStack.getItem()); tick ++; float f = tick * (float)Math.PI * -0.1F; _default.body.getChild("body").yRot = tick * Mth.sin(f) * 5.0F; } I want to animate leftfether,rightfether by itself
April 18, 20223 yr Author Sorry, it was still in error. _default.body.yRot = tick * Mth.sin(f) * 5.0F; //working _default.body.getChild("body").yRot = tick * Mth.sin(f) * 5.0F; //not working _default.body.getChild("RightFeather").yRot = tick * Mth.sin(f) * 5.0F; //not working armorModel.body.getChild("body").yRot = tick * Mth.sin(f) * 5.0F; //not working armorModel.body.getChild("RightFeather").yRot = tick * Mth.sin(f) * 5.0F; //not working It is impossible to get this way Error Caused by: java.util.NoSuchElementException: Can't find part body --> Ah It may work. just a minute Edited April 18, 20223 yr by ocome
April 18, 20223 yr Author Yes, I understand now. I seem to have gone wrong while messing with getChild. I also have a better understanding of the model specifications Thanks for the support! Edited April 18, 20223 yr by ocome
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.