Posted March 16, 20178 yr Hello, i need help with my java code because the armor texture don't work in game .. i put down my code Sorry for my English, I'm a french guy !! <3 Here it's the class : ItemRubyArmor Spoiler package items; import com.neverslands.tutorial.Reference; import com.neverslands.tutorial.Tutorial; import init.ModArmor; import net.minecraft.entity.Entity; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; public class ItemRubyArmor extends ItemArmor { public ItemRubyArmor(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn, String unlocalizedName) { super(materialIn, renderIndexIn, equipmentSlotIn); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MOD_ID, unlocalizedName)); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { String layer = "1"; if(type == null) type =""; if(EntityEquipmentSlot.LEGS.equals(ModArmor.rubyleggings)) { layer = "2"; } else if(EntityEquipmentSlot.HEAD.equals(ModArmor.rubyhelmet) || EntityEquipmentSlot.CHEST.equals(ModArmor.rubychestplate) || EntityEquipmentSlot.FEET.equals(ModArmor.rubyboots)) { layer = "1"; } return "ntm:textures/models/armor/ruby_layer_" + layer + ".png"; } } Here it's the class : ModArmor Spoiler package init; import java.util.logging.Logger; import com.neverslands.tutorial.Reference; import com.neverslands.tutorial.Tutorial; import items.ItemRubyArmor; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.common.registry.GameRegistry; import scala.actors.threadpool.helpers.Utils; public class ModArmor { public static ArmorMaterial rubyMaterial = EnumHelper.addArmorMaterial("tin", Reference.MOD_ID + ":tin", 15, new int[] {3,8,8,3}, 9, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 2.0F); public static Item rubyhelmet; public static Item rubychestplate; public static Item rubyleggings; public static Item rubyboots; public static void init() { rubyhelmet = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.HEAD, "rubyhelmet").setCreativeTab(Tutorial.tabTutorial); rubychestplate = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.CHEST, "rubychestplate").setCreativeTab(Tutorial.tabTutorial); rubyleggings = new ItemRubyArmor(rubyMaterial, 2, EntityEquipmentSlot.LEGS, "rubyleggings").setCreativeTab(Tutorial.tabTutorial); rubyboots = new ItemRubyArmor(rubyMaterial, 1, EntityEquipmentSlot.FEET, "rubyboots").setCreativeTab(Tutorial.tabTutorial); } public static void register() { GameRegistry.register(rubyhelmet); GameRegistry.register(rubychestplate); GameRegistry.register(rubyleggings); GameRegistry.register(rubyboots); } public static void registerRenders() { registerRender(rubyhelmet); registerRender(rubychestplate); registerRender(rubyleggings); registerRender(rubyboots); } private static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } }
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.