WARNING: IF YOU DO NOT KNOW ANYTHING ABOUT JAVA, PLEASE LEARN THE BASICS BEFORE ATTEMPTING TO FOLLOW ANY MODDING TUTORIALS!!!!!
Let's start by creating our Armor's Items. Create a class called ArmorHandler in your Handler package. Within this we need to create our init, register, registerRenders, and registerRender(Item item) methods. Next wee need to create the items for our Armor.
1 2 3 4 | public static Item tutHelmet; public static Item tutChest; public static Item tutLegs; public static Item tutBoots; |
We need to initialize them using a class we will create called ItemTutArmor. We are going to give it the parameters of NAME, CREATIVE TAB, ARMOR MATERIAL (we will create our own), and RENDER INDEX, EQUIPMENTSLOT.
The name and creative tab are pretty much self explanatory. The armor material is what will be our armor's durability, armor texture, strength, etc. The render index is what armor model it will use. Legs use a different model than the others. EquipmentSlot is what slot the armor is gonna go into, helmet goes into HEAD, chest goes into CHEST, etc.
1 2 3 4 | tutHelmet = new ItemTutArmor("tut_helmet", CreativeTabHandler.tabCombat, MaterialHandler.TUTORIAL_ARMOR, 0, EntityEquipmentSlot.HEAD); tutChest = new ItemTutArmor("tut_chest", CreativeTabHandler.tabCombat, MaterialHandler.TUTORIAL_ARMOR, 0, EntityEquipmentSlot.CHEST); tutLegs = new ItemTutArmor("tut_legs", CreativeTabHandler.tabCombat, MaterialHandler.TUTORIAL_ARMOR, 1, EntityEquipmentSlot.LEGS); tutBoots = new ItemTutArmor("tut_boots", CreativeTabHandler.tabCombat, MaterialHandler.TUTORIAL_ARMOR, 0, EntityEquipmentSlot.FEET); |
Now we need to create the ItemTutArmor class. We need to set it up so that it utilizes our name and creative tab.
1 2 3 4 5 6 | public ItemTutArmor(String name, CreativeTabs tab, ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) { super(materialIn, renderIndexIn, equipmentSlotIn); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); } |
We also need to extend our class to ItemArmor. Once you have done that, let's go ahead and create our ArmorMaterial. Our Armor Material is going to go into our MaterialHandler. We need to create a constant that will hold our armor material for us.
1 | public static final ArmorMaterial NAME_OF_MATERIAL = EnumHelper.addArmorMaterial("<materialName>", "<textureName>", <durability>, new int[]{<headArmorPiecesAmount>, <chestArmorPiecesAmount>, <legsArmorPiecesAmount>, <feetArmorPiecesAmount>}, <enchantability>, <sound>, <toughtness>); |
This is the format that we will go by for our material. Replace the corresponding name with whatever values that you want there. For me I am gonna go with the following:
1 | public static final ArmorMaterial TUTORIAL_ARMOR = EnumHelper.addArmorMaterial("tutorial_armor", "tut:tutorial_armor", 1500, new int[]{3, 5, 4, 2}, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 8F); |
The name is the registry name, I have already went over this. The texture name is the name of the armor model texture. It is in the format of texture_name_layer_0 or texture_name_layer_1. As mentioned earlier, there is two different models. layer_0 is the layer that includes the helmet, chest, and boots. layer_1 is the layer with the pants. Next, the durability is how many times the armor can be hit before breaking. The integer array with the 4 different integers is how many halves of armor will be filled in the GUI, at the armor bar. The enchantability is the same as the tool enchantability. The sound is the sound that is played when you put on the armor. Lastly, the toughness is how tough it is, obviously. I don't know much about this but when I do, I will be sure to update.
Next is to create the armor textures. Make the textures. I will be borrowing from my mod, Mara: The Ultimate Nightmare (be sure to check it out. Link at the end of the tutorial!). We need to put the armor model textures in the folder textures/models/armor. Save your textures in the correct locations (the item textures in the item texture location). Register the armor and it's rendering and you finally have armor.
MAKE SURE YOU PUT YOUR ARMORHANDLER INIT, REGISTER, AND REGISTERRENDERS IN YOUR PROXIES!!!
The following is my result:
=====================================Armor Properties=====================================
If you would like to add potion effects to your armor, then here is how to:
Go into your Armor class and put in the onArmorTick method.
1 2 3 4 | @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { } |
Within this we need to call on the player method addPotionEffect and pass in a new instance of PotionEffect. We then need to pass in an argument that is the potion effect (you can get the effect from MobEffects class). We also need to pass in the duration (in ticks) and the amplifier (whether it is I, II, III, etc).
1 | player.addPotionEffect(new PotionEffect(MobEffects.HEALTH_BOOST, 100, 2)); |
I am adding a health boost when the armor is worn.
Congratulations, you just successfully made armor.
No json for armor?
ReplyDeletelook down there m8
Delete|
V
I'm sure that the JSONs are left for us to figure out.... though I didn't see the link for the Mara: The ultimate nightmare link.... That would help out.
ReplyDeleteYou don't need a json for the armor lmao, that's java coded and ya don't have to do it.
DeleteThis comment has been removed by the author.
ReplyDeleteHi Alex do you know how i can add a potion effect only if the player have the full armor ?
ReplyDeletehealth boost is showing but in survival you will see it's not working because it's applying the effect every tick. If you put 100 tick for the duration, your health will reset after 100 tick.
ReplyDelete