In my commonproxy.java:
public void preInit(FMLPreInitializationEvent event) {
kaktusItems.createItems();
and then in my kaktusItems.java file:
package kaktus.mods.kaktusmod.items;
import kaktus.mods.kaktusmod.Config;
import kaktus.mods.kaktusmod.KaktusMod;
import kaktus.mods.kaktusmod.items.armor.TurtleshellArmor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class kaktusItems {
public static Item turtleShellHelmet;
public static Item turtleShellChestplate;
public static Item turtleShellLeggings;
public static Item turtleShellBoots;
public static ArmorMaterial turtleArmorMaterial = EnumHelper.addArmorMaterial(
"turtleArmorMaterial",
Config.MODID + ":turtleArmorMaterial",
1000,
new int[] {3, 8, 6, 3},
30);
public static void createItems(){
turtleShellHelmet = new TurtleshellArmor("turtleshellhelmet", turtleArmorMaterial, 1, 0);
turtleShellChestplate = new TurtleshellArmor("turtleshellchestplate", turtleArmorMaterial, 1, 1).setCreativeTab(KaktusMod.kaktusmodcreativetab);
turtleShellLeggings = new TurtleshellArmor("turtleshellleggings", turtleArmorMaterial, 2, 2).setCreativeTab(KaktusMod.kaktusmodcreativetab);
turtleShellBoots = new TurtleshellArmor("turtleshellboots", turtleArmorMaterial, 1, 3).setCreativeTab(KaktusMod.kaktusmodcreativetab);
registerItems();
}
public static void registerItems(){
GameRegistry.registerItem(turtleShellHelmet, turtleShellHelmet.getUnlocalizedName().substring(5));
GameRegistry.registerItem(turtleShellChestplate, turtleShellChestplate.getUnlocalizedName().substring(5));
GameRegistry.registerItem(turtleShellLeggings, turtleShellLeggings.getUnlocalizedName().substring(5));
GameRegistry.registerItem(turtleShellBoots, turtleShellBoots.getUnlocalizedName().substring(5));
}
public static void registerRenders(){
registerRender(turtleShellHelmet);
registerRender(turtleShellChestplate);
registerRender(turtleShellLeggings);
registerRender(turtleShellBoots);
}
public static void registerRender(Item item){
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
item, 0, new ModelResourceLocation(
Config.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}
Anf then finally my armor class:
package kaktus.mods.kaktusmod.items.armor;
import java.util.List;
import kaktus.mods.kaktusmod.Config;
import kaktus.mods.kaktusmod.KaktusMod;
import kaktus.mods.kaktusmod.items.kaktusItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TurtleshellArmor extends ItemArmor implements ISpecialArmor {
public static final Enchantment[] helmetTurtleEnchantments = { Enchantment.thorns };
public static final int[] helmetTurtleEnchantmentLevels = { 3 };
public static final PotionEffect[] helmetTurtleEffects = { new PotionEffect(Potion.waterBreathing.id, 200, 0) };
public TurtleshellArmor(String unlocalizedName, ArmorMaterial material, int renderIndex, int armorType) {
super(material, renderIndex, armorType);
this.setUnlocalizedName(unlocalizedName);
//this.setCreativeTab(KaktusMod.kaktusmodcreativetab);
this.maxStackSize = 1;
}
@Override
public void onCreated(ItemStack itemStack, World worldIn, EntityPlayer player) {
if (itemStack.getDisplayName().equals("turtleshellhelmet")) {
for (int i = 0; i < helmetTurtleEnchantments.length; i++) {
itemStack.addEnchantment(helmetTurtleEnchantments[i], helmetTurtleEnchantmentLevels[i]);
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) {
ItemStack itemStack = new ItemStack(itemIn, 1, 0);
if (itemIn.equals(kaktusItems.turtleShellHelmet)) {
for (int i = 0; i < helmetTurtleEnchantments.length; i++) {
itemStack.addEnchantment(helmetTurtleEnchantments[i], helmetTurtleEnchantmentLevels[i]);
}
}
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if (itemStack.getItem().equals(kaktusItems.turtleShellHelmet)) {
this.effectPlayer(player, Potion.waterBreathing, 0);
}
if (this.isWearingFullSet(player, kaktusItems.turtleShellHelmet, kaktusItems.turtleShellChestplate, kaktusItems.turtleShellLeggings, kaktusItems.turtleShellBoots)) {
this.effectPlayer(player, Potion.regeneration, 1);
}
}
private void effectPlayer(EntityPlayer player, Potion potion, int amplifier) {
//Always effect for 8 seconds, then refresh
if (player.getActivePotionEffect(potion) == null || player.getActivePotionEffect(potion).getDuration() <= 1)
player.addPotionEffect(new PotionEffect(potion.id, 159, amplifier, true, true));
}
private boolean isWearingFullSet(EntityPlayer player, Item helmet, Item chestplate, Item leggings, Item boots) {
return player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() == helmet
&& player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == chestplate
&& player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(1).getItem() == leggings
&& player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(0).getItem() == boots;
}
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
int slot) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
// TODO Auto-generated method stub
}
}
And then in my kaktusItems.java: