Commit 1207c0bc authored by Zandor Smith's avatar Zandor Smith 💻

Changed armor type from int to an enum type.

parent dd1eef0b
package com.advancedmods.advancedtools.common.generic;
import com.advancedmods.advancedtools.core.ATProps;
import com.advancedmods.advancedtools.core.ArmorType;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
......@@ -9,23 +10,22 @@ import net.minecraft.item.ItemStack;
*/
public class ATItemArmor extends ItemArmor {
public ATItemArmor(ArmorMaterial material, int j, int j1) {
super(material, j, j);
}
@Override
public String getUnlocalizedName()
{
return String.format("item.%s%s", ATProps.modid.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
public ATItemArmor(ArmorMaterial material, ArmorType type) {
super(material, 0, type.getId());
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return String.format("item.%s%s", ATProps.modid.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
public String getUnlocalizedName() {
return String.format("item.%s%s", ATProps.modid.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
@Override
public String getUnlocalizedName(ItemStack itemStack) {
return String.format("item.%s%s", ATProps.modid.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
protected String getUnwrappedUnlocalizedName(String unlocalizedName) {
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
}
......@@ -4,6 +4,7 @@ import com.advancedmods.advancedtools.AdvancedTools;
import com.advancedmods.advancedtools.common.generic.ATItemArmor;
import com.advancedmods.advancedtools.core.ATProps;
import com.advancedmods.advancedtools.core.ATRegistry;
import com.advancedmods.advancedtools.core.ArmorType;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
......@@ -12,26 +13,24 @@ import net.minecraft.item.ItemStack;
*/
public class EmeraldArmor extends ATItemArmor {
public EmeraldArmor(String name, String texture, ArmorMaterial material, int j) {
super(material, j, j);
this.setCreativeTab(AdvancedTools.tabCombat);
this.setUnlocalizedName(name);
this.setTextureName(ATProps.modid.toLowerCase() + ":" + texture);
this.setMaxDamage(material.getDurability(j));
this.setMaxStackSize(1);
}
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem() == ATRegistry.emeraldHelmet
|| stack.getItem() == ATRegistry.emeraldChestplate
|| stack.getItem() == ATRegistry.emeraldBoots)
return ATProps.modid.toLowerCase() + ":textures/models/armor/emerald_1.png";
if (stack.getItem() == ATRegistry.emeraldLeggings)
return ATProps.modid.toLowerCase() + ":textures/models/armor/emerald_2.png";
return null;
}
public EmeraldArmor(String name, String texture, ArmorMaterial material, ArmorType type) {
super(material, type);
this.setCreativeTab(AdvancedTools.tabCombat);
this.setUnlocalizedName(name);
this.setTextureName(ATProps.modid.toLowerCase() + ":" + texture);
this.setMaxDamage(material.getDurability(type.getId()));
this.setMaxStackSize(1);
}
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem() == ATRegistry.emeraldHelmet
|| stack.getItem() == ATRegistry.emeraldChestplate
|| stack.getItem() == ATRegistry.emeraldBoots)
return ATProps.modid.toLowerCase() + ":textures/models/armor/emerald_1.png";
if (stack.getItem() == ATRegistry.emeraldLeggings)
return ATProps.modid.toLowerCase() + ":textures/models/armor/emerald_2.png";
return null;
}
}
......@@ -92,10 +92,10 @@ public class ATRegistry {
//public static Item emeraldAxe = new EmeraldAxe(5002, emerald);
//public static Item emeraldSword = new EmeraldSword(5003, emerald);
//public static Item emeraldHoe = new EmeraldHoe(5004, emerald);
public static Item emeraldHelmet = new EmeraldArmor("EmeraldHelmet", "emeraldhelmet", emeraldArmor, 0);
public static Item emeraldChestplate = new EmeraldArmor("EmeraldChestplate", "emeraldchestplate", emeraldArmor, 1);
public static Item emeraldLeggings = new EmeraldArmor("EmeraldLeggings", "emeraldleggings", emeraldArmor, 2);
public static Item emeraldBoots = new EmeraldArmor("EmeraldBoots", "emeraldboots", emeraldArmor, 3);
public static Item emeraldHelmet = new EmeraldArmor("EmeraldHelmet", "emeraldhelmet", emeraldArmor, ArmorType.HELMET);
public static Item emeraldChestplate = new EmeraldArmor("EmeraldChestplate", "emeraldchestplate", emeraldArmor, ArmorType.CHESTPLATE);
public static Item emeraldLeggings = new EmeraldArmor("EmeraldLeggings", "emeraldleggings", emeraldArmor, ArmorType.LEGGINGS);
public static Item emeraldBoots = new EmeraldArmor("EmeraldBoots", "emeraldboots", emeraldArmor, ArmorType.BOOTS);
// Enderion
// TODO: Change Tool and Armor material values to fit Enderion.
......
package com.advancedmods.advancedtools.core;
public enum ArmorType {
HELMET(0),
CHESTPLATE(1),
LEGGINGS(2),
BOOTS(3);
private final int id;
ArmorType(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment