Posted December 19, 20222 yr I use initializeClient and IClientItemExtensions to make an armature. everything works, texture and movement synchronization, except the position of the elements in relation to the body. in other words: the helmet floats two blocks away from the head, the torso rotated parallel to the body, and so on. I thought about changing position, scale and rotation manually in IClientItemExtensions, but nothing changes in game. It seems like everything I do, the game undoes. Below is an example of what I did. I also thought about doing the modeling in blochbench with a model by steve(HumanoidModel), but I can't find that model for blochbench anywhere, could someone tell me where a perfect replica exists? public class SteelArmorItem extends ArmorItem { public SteelArmorItem(EquipmentSlot equipmentSlot, Properties properties) { super(SteelHelmetMaterial, equipmentSlot, properties); } @Override public @Nullable String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return "mymod:textures/models/armor/steel_material_layer_1.png"; } public void initializeClient(Consumer<IClientItemExtensions> consumer) { consumer.accept(new IClientItemExtensions() { public HumanoidModel<?> getHumanoidArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> defaultModel) { HumanoidModel armorModel = new HumanoidModel(createBodyLayer()); armorModel.head.xScale = 3; // But the scale not work armorModel.head.yScale = 3; // But the scale not work armorModel.head.zScale = 3; // But the scale not work armorModel.head.x = 3; // But the head position don't set armorModel.head.y = 3; // But the head position don't set armorModel.head.z = 3; // But the head position don't set return armorModel; } public static ModelPart createBodyLayer() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); /* the Mashes precessing */ return LayerDefinition.create(meshdefinition, 128, 128).bakeRoot(); } }); } }
December 22, 20222 yr First, of course they don't. Those are set by the game itself when trying to render the humanoid model, so they'll be set to the correct values afterward. If you wanted to do offsets, you should create something that builds off the main armor model. Secondly, that is not how you create a model. The model should only be constructed once and should be baked from the EntityModelSet. Then, you should pass in the model into the method itself.
December 23, 20222 yr Author At first I'm doing it for testing purposes, as I've never made armor before. Question, the difference between the EntityModelSet and the Model itself is that one needs Json and the other doesn't. However, I will still have problems with rotation. Speaking only of the helmet and the head. The head rotates around in reference to the body and not the head, so I have to make adjustments to the position of the head.
December 23, 20222 yr 1 hour ago, DouglasRafael said: Question, the difference between the EntityModelSet and the Model itself is that one needs Json and the other doesn't. That's not a question and that is not true. The EntityModelSet is responsible for holding the baked models (whether from code or json (which is not possible without a mod)) for a given model layer location which can be registered via`EntityRenderersEvent$RegisterLayerDefinitions#registerLayerDefinition` on the forge event bus. As for the Model, it just represents what the state of the parts that are baked when rendering. 1 hour ago, DouglasRafael said: Speaking only of the helmet and the head. The head rotates around in reference to the body and not the head, so I have to make adjustments to the position of the head. That's just a badly constructed model. In general, the way to add to an existing humanoid model is to create a root which has the same offset as the humanoid model part. From there, you add children to that model part as then the transformations are properly mapped. Please provide the code for your model rather than just telling me it doesn't work.
December 24, 20222 yr Author is Into createBodyLayer method. Everything works except the sync. For example, the head refers to the player's entire body, not just the player's head. Spoiler package net.douglas.modcraft.items.armors.armor; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.Model; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.*; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.client.extensions.common.IClientItemExtensions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; public class SteelArmorItem extends ArmorItem { public boolean isLeggings; public SteelArmorItem(EquipmentSlot equipmentSlot, Properties properties) { super(STEEL_MATERIAL, equipmentSlot, properties); if(equipmentSlot == EquipmentSlot.CHEST || equipmentSlot == EquipmentSlot.HEAD){ isLeggings=false; }else{ isLeggings=true; } } @Override public @Nullable String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { if(isLeggings) { return "modcraft:textures/models/armor/steel_infantary_armor_texture_layer_2.png"; }else{ return "modcraft:textures/models/armor/steel_infantary_armor_texture_layer_1.png"; } } public void initializeClient(Consumer<IClientItemExtensions> consumer) { consumer.accept(new IClientItemExtensions() { @Override // faz tudo que mandar, entretanto não tem original. public @NotNull Model getGenericArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> originalModel) { HumanoidModel armorModel = new HumanoidModel(createBodyLayer()); armorModel.crouching = entityLiving.isShiftKeyDown(); armorModel.riding = originalModel.riding; armorModel.young = entityLiving.isBaby(); originalModel.copyPropertiesTo(armorModel); return armorModel; } public static ModelPart createBodyLayer() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); PartDefinition head = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(36, 0).addBox(-5.0F, -32.0F, -5.0F, 10.0F, 10.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 23.0F, 0.0F)); head.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(22, 80).addBox(-3.0F, -26.0F, -29.0F, 5.0F, 14.0F, 5.0F, new CubeDeformation(0.0F)).texOffs(0, 47).addBox(-6.0F, -26.0F, -20.0F, 12.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -0.7854F, 0.0F, 0.0F)); PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 0.0F)); body.addOrReplaceChild("FlancoChest_r1", CubeListBuilder.create().texOffs(47, 20).addBox(-7.0F, -14.0F, -1.0F, 14.0F, 4.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.6545F, 0.0F, 0.0F)); body.addOrReplaceChild("BackChest_r1", CubeListBuilder.create().texOffs(44, 35).addBox(-10.0F, -25.0F, 10.0F, 7.0F, 11.0F, 12.0F, new CubeDeformation(0.0F)).texOffs(0, 0).addBox(-4.0F, -24.0F, 6.0F, 8.0F, 6.0F, 20.0F, new CubeDeformation(0.0F)).texOffs(0, 25).addBox(-14.0F, -15.0F, 11.0F, 18.0F, 12.0F, 10.0F, new CubeDeformation(0.0F)).texOffs(30, 58).addBox(-3.0F, -24.0F, 11.0F, 6.0F, 12.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(16.0F, 0.0F, 0.0F, 0.0F, -1.5708F, 0.0F)); partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(62, 73).addBox(-9.0F, -23.0F, -3.0F, 5.0F, 13.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(0, 0).addBox(4.0F, -23.0F, -3.0F, 4.0F, 13.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(1.0F, 24.0F, 0.0F)); partdefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 78).addBox(0.0F, -13.0F, -3.0F, 5.0F, 13.0F, 6.0F, new CubeDeformation(0.0F)).texOffs(0, 63).addBox(-1.0F, -9.0F, -4.0F, 6.0F, 6.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offset(-5.0F, 24.0F, 0.0F)); partdefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(76, 0).addBox(-5.0F, -13.0F, -3.0F, 5.0F, 13.0F, 6.0F, new CubeDeformation(0.0F)).texOffs(62, 58).addBox(-5.0F, -9.0F, -4.0F, 6.0F, 6.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offset(5.0F, 24.0F, 0.0F)); partdefinition.addOrReplaceChild("hat", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 0.0F)); return LayerDefinition.create(meshdefinition, 128, 128).bakeRoot(); } }); } private static final ArmorMaterial STEEL_MATERIAL = new ModArmorMaterial( "steel_infantary_armor_texture", 500, new int[] { 20, 40, 50, 10 }, 300, SoundEvents.ARMOR_EQUIP_DIAMOND, 0.0f, 0.0f, () -> Ingredient.of(Items.IRON_INGOT) ); } Below what happens with image: Spoiler Spoiler
December 25, 20222 yr The model is incorrect, as I've stated. The position offsets of the base model parts (not your additions) need to be set to the offsets of the original humanoid model, which you can find just by looking at the mesh construction. Additionally, since you're using a humanoid model, go back to using the method you were using previously. You have no reason to set the data yourself. Parts should not be rotated unless they are the main model parts or that it is needed for specific stylization. Additionally, you don't need to replace parts that you have not modified in the slightest, and if you are adding cubes, you should to add them as children to the main model itself. Finally, if you are adding cubes to a model part, you need to add back the cubes from the original model as they will be replaced.
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.