diff --git a/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java b/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java index c6d014b5..be384db5 100644 --- a/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java +++ b/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java @@ -2,11 +2,10 @@ import net.minecraft.item.ItemStack; -public class ItemHorn extends MItem implements IPlating +public class ItemHorn extends MItem implements IItemAddon { public ItemHorn() { - platings.put("horn", this); addons.add(this); } @@ -24,49 +23,19 @@ public boolean canApply(ItemStack platable) @Override public void apply(ItemStack platable) { - MItemTool.setPlating(platable, this); + MItemTool.setHorned(platable, true); } @Override public void unapply(ItemStack platable) { - MItemTool.setPlating(platable, null); + MItemTool.setHorned(platable, false); } @Override public boolean isApplied(ItemStack platable) { - return MItemTool.getPlating(platable) == this; - } - - @Override - public String getType() - { - return "horn"; - } - - @Override - public String getType(ItemStack stack) - { - return "horn"; - } - - @Override - public float getEntityDamage() - { - return 1F; - } - - @Override - public float getDigSpeed() - { - return 1.1F; - } - - @Override - public int getDurability() - { - return 16; + return MItemTool.isHorned(platable); } @Override diff --git a/src/main/java/minestrapteam/minestrappolation/item/MItemSword.java b/src/main/java/minestrapteam/minestrappolation/item/MItemSword.java index 1f6fec16..25efdbd3 100644 --- a/src/main/java/minestrapteam/minestrappolation/item/MItemSword.java +++ b/src/main/java/minestrapteam/minestrappolation/item/MItemSword.java @@ -26,6 +26,7 @@ public class MItemSword extends ItemSword implements IPlatable private ToolMaterial material; private boolean ignites; + private IIcon hornIcon; private Map overlayIcons = new HashMap(); public MItemSword(ToolMaterial material) @@ -110,10 +111,18 @@ public boolean requiresMultipleRenderPasses() return true; } + @Override + public int getRenderPasses(int metadata) + { + return 3; + } + @Override public void registerIcons(IIconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon(this.getIconString()); + this.hornIcon = iconRegister.registerIcon(MAssetManager.getWeaponTexture("horned_sword_overlay")); + ItemStack thisStack = new ItemStack(this, 1, 0); for (Entry e : IPlating.platings.entrySet()) @@ -137,7 +146,7 @@ public void registerIcons(IIconRegister iconRegister) public IIcon getIcon(ItemStack stack, int renderPass) { IIcon icon = null; - if (renderPass == 1) + if (renderPass == 2) { IPlating plating = MItemTool.getPlating(stack); if (plating != null) @@ -145,6 +154,13 @@ public IIcon getIcon(ItemStack stack, int renderPass) icon = this.overlayIcons.get(plating.getType()); } } + else if (renderPass == 1) + { + if (MItemTool.isHorned(stack)) + { + icon = this.hornIcon; + } + } return icon == null ? this.itemIcon : icon; } } diff --git a/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java b/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java index 32dedea4..c463c942 100644 --- a/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java +++ b/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java @@ -30,6 +30,7 @@ public class MItemTool extends ItemTool implements IPlatable { public static final UUID PLATING_UUID = UUID.fromString("DB3F55D3-645C-4F38-A497-9C13A33DB5CF"); + public static final UUID HORN_UUID = UUID.fromString("DB3F55D3-645C-4F38-A497-9C13A33DB5DF"); protected boolean ignites; protected boolean weapon; @@ -82,22 +83,40 @@ public static IPlating getPlating(ItemStack stack) return null; } - public static float getPoisonLevel(ItemStack stack) + public static void setPlating(ItemStack stack, IPlating plating) + { + if (stack.stackTagCompound == null) + { + stack.stackTagCompound = new NBTTagCompound(); + } + stack.stackTagCompound.setString("Plating", plating == null ? "" : plating.getType()); + } + + public static boolean isHorned(ItemStack stack) { if (stack.stackTagCompound != null) { - return stack.stackTagCompound.getFloat("PoisonLevel"); + return stack.stackTagCompound.getBoolean("Horned"); } - return 0F; + return false; } - public static void setPlating(ItemStack stack, IPlating plating) + public static void setHorned(ItemStack stack, boolean horned) { if (stack.stackTagCompound == null) { stack.stackTagCompound = new NBTTagCompound(); } - stack.stackTagCompound.setString("Plating", plating == null ? "" : plating.getType()); + stack.stackTagCompound.setBoolean("Horned", horned); + } + + public static float getPoisonLevel(ItemStack stack) + { + if (stack.stackTagCompound != null) + { + return stack.stackTagCompound.getFloat("PoisonLevel"); + } + return 0F; } public static void setPoisonLevel(ItemStack stack, float level) @@ -177,6 +196,11 @@ public static void addInformation(ItemStack stack, List list) { list.add(I18n.getString("item.poison_sword.desc", poisonLevel)); } + + if (isHorned(stack)) + { + list.add(I18n.getString("item.horned_sword.desc")); + } } @Override @@ -255,6 +279,12 @@ public static Multimap getAttributeModifiers(Multimap multimap, ItemStack stack) AttributeModifier modifier = new AttributeModifier(PLATING_UUID, "Plating Modifier", plating.getEntityDamage(), 0); multimap.put("generic.attackDamage", modifier); } + + if (isHorned(stack)) + { + AttributeModifier modifier = new AttributeModifier(PLATING_UUID, "Plating Modifier", 2, 0); + multimap.put("generic.attackDamage", modifier); + } return multimap; } diff --git a/src/main/resources/assets/minestrappolation/textures/items/weapons/horn_sword_overlay.png b/src/main/resources/assets/minestrappolation/textures/items/weapons/horned_sword_overlay.png similarity index 100% rename from src/main/resources/assets/minestrappolation/textures/items/weapons/horn_sword_overlay.png rename to src/main/resources/assets/minestrappolation/textures/items/weapons/horned_sword_overlay.png