From 943a4a14cc24fde7d14f5d9eb9332501ce73ba14 Mon Sep 17 00:00:00 2001 From: Clashsoft Date: Wed, 6 Aug 2014 00:02:11 +0200 Subject: [PATCH] Poisoned Swords! --- .../minestrappolation/item/ItemHorn.java | 7 +--- .../item/ItemPoisonSack.java | 42 +++++++++++++++++++ .../minestrappolation/item/MItemTool.java | 18 ++++---- .../minestrappolation/lib/MItems.java | 2 +- .../assets/minestrappolation/lang/en_US.lang | 4 +- 5 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 src/main/java/minestrapteam/minestrappolation/item/ItemPoisonSack.java diff --git a/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java b/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java index be384db5..1225c4e5 100644 --- a/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java +++ b/src/main/java/minestrapteam/minestrappolation/item/ItemHorn.java @@ -12,12 +12,7 @@ public ItemHorn() @Override public boolean canApply(ItemStack platable) { - if (platable.getItem() instanceof IPlatable) - { - IPlatable iplatable = (IPlatable) platable.getItem(); - return "sword".equals(iplatable.getType()); - } - return false; + return platable.getItem() instanceof MItemSword; } @Override diff --git a/src/main/java/minestrapteam/minestrappolation/item/ItemPoisonSack.java b/src/main/java/minestrapteam/minestrappolation/item/ItemPoisonSack.java new file mode 100644 index 00000000..394ea7ef --- /dev/null +++ b/src/main/java/minestrapteam/minestrappolation/item/ItemPoisonSack.java @@ -0,0 +1,42 @@ +package minestrapteam.minestrappolation.item; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class ItemPoisonSack extends Item implements IItemAddon +{ + public ItemPoisonSack() + { + addons.add(this); + } + + @Override + public boolean canApply(ItemStack platable) + { + return platable.getItem() instanceof MItemSword && MItemTool.getPoisonLevel(platable) < 4F; + } + + @Override + public void apply(ItemStack platable) + { + MItemTool.setPoisonLevel(platable, 4F); + } + + @Override + public void unapply(ItemStack platable) + { + MItemTool.setPoisonLevel(platable, 0F); + } + + @Override + public boolean isApplied(ItemStack platable) + { + return MItemTool.getPoisonLevel(platable) == 4F; + } + + @Override + public int getCount(ItemStack platable) + { + return 1; + } +} diff --git a/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java b/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java index c463c942..0fc361c5 100644 --- a/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java +++ b/src/main/java/minestrapteam/minestrappolation/item/MItemTool.java @@ -29,8 +29,8 @@ 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"); + public static final UUID PLATING_UUID = UUID.fromString("CB3F55D3-745C-4F38-A497-9C13A33DB5CF"); + public static final UUID HORN_UUID = UUID.fromString("CB3F55D3-845C-4F38-A497-9C13A33DB5CF"); protected boolean ignites; protected boolean weapon; @@ -185,12 +185,6 @@ public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingB public static void addInformation(ItemStack stack, List list) { - IPlating plating = getPlating(stack); - if (plating != null) - { - list.add(I18n.getString("item.plating." + plating.getType() + ".desc")); - } - float poisonLevel = getPoisonLevel(stack); if (poisonLevel > 0F) { @@ -201,6 +195,12 @@ public static void addInformation(ItemStack stack, List list) { list.add(I18n.getString("item.horned_sword.desc")); } + + IPlating plating = getPlating(stack); + if (plating != null) + { + list.add(I18n.getString("item.plating." + plating.getType() + ".desc")); + } } @Override @@ -282,7 +282,7 @@ public static Multimap getAttributeModifiers(Multimap multimap, ItemStack stack) if (isHorned(stack)) { - AttributeModifier modifier = new AttributeModifier(PLATING_UUID, "Plating Modifier", 2, 0); + AttributeModifier modifier = new AttributeModifier(HORN_UUID, "Horn Modifier", 2, 0); multimap.put("generic.attackDamage", modifier); } return multimap; diff --git a/src/main/java/minestrapteam/minestrappolation/lib/MItems.java b/src/main/java/minestrapteam/minestrappolation/lib/MItems.java index aabff6dd..8b962fc7 100644 --- a/src/main/java/minestrapteam/minestrappolation/lib/MItems.java +++ b/src/main/java/minestrapteam/minestrappolation/lib/MItems.java @@ -299,7 +299,7 @@ public static void init() flesh = new MItemFood(4, 0.35F).setPotionEffect(Potion.hunger.id, 20, 0, 0.05F).setCreativeTab(tabFood).setTextureName(MAssetManager.getFoodTexture("flesh")); marrow = new MItemFood(5, 0.32F).setCreativeTab(tabBrewing).setTextureName(MAssetManager.getFoodTexture("marrow_bowl")); legSpider = new MItem().setCreativeTab(tabBrewing).setTextureName(MAssetManager.getMobTexture("spider_leg")); - poisonSack = new MItem().setCreativeTab(tabMaterials).setTextureName(MAssetManager.getMobTexture("poison_sack")); + poisonSack = new ItemPoisonSack().setCreativeTab(tabMaterials).setTextureName(MAssetManager.getMobTexture("poison_sack")); guano = new ItemGuano().setCreativeTab(tabMaterials).setTextureName(MAssetManager.getTexture("guano")); carcassSilverfish = new MItem().setCreativeTab(tabBrewing).setTextureName(MAssetManager.getMobTexture("silverfish_carcass")); hideCreeper = new MItem().setCreativeTab(tabMaterials).setTextureName(MAssetManager.getMobTexture("creeper_hide")); diff --git a/src/main/resources/assets/minestrappolation/lang/en_US.lang b/src/main/resources/assets/minestrappolation/lang/en_US.lang index b7f021ea..47ad9350 100644 --- a/src/main/resources/assets/minestrappolation/lang/en_US.lang +++ b/src/main/resources/assets/minestrappolation/lang/en_US.lang @@ -992,7 +992,9 @@ item.plating.tin.desc=Tin-Plated item.plating.bronze.desc=Bronze-Plated item.plating.steel.desc=Steel-Plated item.plating.meurodite.desc=Meurodite-Plated -item.plating.horn.desc=Horned + +item.horned_sword.desc=Horned +item.poison_sword.desc=§aPoisoned: %.1d lock.locked=This block has been locked by %1$s. You need the key to open it! lock.locked.no_owner=This block is locked. You need a key to open it.