diff options
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java')
| -rwxr-xr-x[-rw-r--r--] | src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java | 320 |
1 files changed, 182 insertions, 138 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java index 6df3b1b..93328c8 100644..100755 --- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -2,6 +2,7 @@ package darkknight.jewelrycraft.item; import java.util.ArrayList;
import java.util.List;
+
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.JewelrycraftMod;
@@ -19,142 +20,185 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector;
import net.minecraftforge.event.entity.player.PlayerEvent;
-public abstract class ItemBaseJewelry extends Item
-{
- public ItemBaseJewelry()
- {
- super();
- setMaxStackSize(1);
- setCreativeTab(JewelrycraftMod.jewelrycraft);
- }
-
- public boolean requiresMultipleRenderPasses()
- {
- return true;
- }
-
- @SideOnly (Side.CLIENT)
- public int getColorFromItemStack(ItemStack stack, int pass)
- {
- if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
- if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.gem(stack));
- else if (JewelryNBT.ingot(stack) != null) return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
- return 16777215;
- }
-
- /**
- * @param stack
- * @return
- */
- public String getItemStackDisplayName(ItemStack stack)
- {
- if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim();
- return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim();
- }
-
- /**
- * allows items to add custom lines of information to the mouseover description.
- *
- * @param stack
- * @param player
- * @param list
- * @param par4
- */
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
- {
- if (stack.hasTagCompound() && ConfigHandler.JEWELRY_INFO){
- ItemStack ingot = JewelryNBT.ingot(stack);
- if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") + ": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " "));
- ItemStack gem = JewelryNBT.gem(stack);
- if (gem != null) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".gem") + ": " + EnumChatFormatting.BLUE + gem.getDisplayName());
- ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
- if (!modifier.isEmpty()) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": ");
- for(int i = 0; i < modifier.size(); i++)
- list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize);
- }
- }
-
- /**
- * @param stack
- * @param player
- */
- public void action(ItemStack item, EntityPlayer player)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.action(item, player, this);
- }
-
- /**
- * @param item
- * @param player
- * @param source
- * @return
- */
- public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if(JewelryNBT.doesModifierExist(item, mod.getModifier())) return mod.onPlayerAttackedCacellable(item, player, source, this, amount);
- return false;
- }
-
- /**
- * @param item
- * @param player
- * @param target
- * @return
- */
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if(JewelryNBT.doesModifierExist(item, mod.getModifier())) return mod.onEntityAttackedCacellable(item, player, target, this, amount);
- return false;
- }
-
- /**
- * @param item
- * @param player
- * @param source
- * @return
- */
- public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, float amount)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerAttacked(item, player, source, this, amount);
- }
-
- /**
- * @param item
- * @param player
- * @param target
- * @return
- */
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onEntityAttacked(item, player, target, this, amount);
- }
-
- public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerDead(item, player, source, this);
- }
-
- public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerRespawn(item, event, this);
- }
-
- public void onJewelryEquipped(ItemStack item)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onJewelryEquipped(item, this);
- }
-
- public void onJewelryUnequipped(ItemStack item)
- {
- for(ModifierEffects mod: ModifierEffects.getEffects())
- if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onJewelryUnequipped(item, this);
- }
+public abstract class ItemBaseJewelry extends Item {
+ public ItemBaseJewelry() {
+ super();
+ setMaxStackSize(1);
+ setCreativeTab(JewelrycraftMod.jewelrycraft);
+ }
+
+ @Override
+ public boolean requiresMultipleRenderPasses() {
+ return true;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getColorFromItemStack(ItemStack stack, int pass) {
+ if (pass == 0 && JewelryNBT.ingot(stack) != null) {
+ return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
+ }
+
+ if (pass == 1 && JewelryNBT.gem(stack) != null) {
+ return JewelrycraftUtil.getColor(JewelryNBT.gem(stack));
+ } else if (JewelryNBT.ingot(stack) != null) {
+ return JewelrycraftUtil.getColor(JewelryNBT.ingot(stack));
+ }
+
+ return 16777215;
+ }
+
+ /**
+ * @param stack
+ * @return
+ */
+ @Override
+ public String getItemStackDisplayName(ItemStack stack) {
+ if (JewelryNBT.ingot(stack) != null && Item
+ .getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0)
+ return JewelryNBT.ingot(stack).getDisplayName()
+ .replace("Ingot", " ").trim()
+ + " "
+ + ("" + StatCollector.translateToLocal(
+ getUnlocalizedNameInefficiently(stack)
+ + ".name")).trim();
+ return ("" + StatCollector.translateToLocal(
+ getUnlocalizedNameInefficiently(stack) + ".name")).trim();
+ }
+
+ /**
+ * allows items to add custom lines of information to the mouseover
+ * description.
+ *
+ * @param stack
+ * @param player
+ * @param list
+ * @param par4
+ */
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer player,
+ List list, boolean par4) {
+ if (stack.hasTagCompound() && ConfigHandler.JEWELRY_INFO) {
+ ItemStack ingot = JewelryNBT.ingot(stack);
+ if (ingot != null && Item.getIdFromItem(
+ JewelryNBT.ingot(stack).getItem()) > 0) {
+ list.add(StatCollector.translateToLocal(
+ "info." + Variables.MODID + ".metal") + ": "
+ + EnumChatFormatting.YELLOW
+ + ingot.getDisplayName().replace(
+ StatCollector.translateToLocal("info."
+ + Variables.MODID + ".ingot"),
+ " "));
+ }
+
+ ItemStack gem = JewelryNBT.gem(stack);
+
+ if (gem != null) {
+ list.add(StatCollector.translateToLocal(
+ "info." + Variables.MODID + ".gem") + ": "
+ + EnumChatFormatting.BLUE + gem.getDisplayName());
+ }
+
+ ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
+
+ if (!modifier.isEmpty())
+ list.add(StatCollector.translateToLocal(
+ "info." + Variables.MODID + ".modifiers") + ": ");
+ for (int i = 0; i < modifier.size(); i++)
+ list.add(EnumChatFormatting.DARK_PURPLE
+ + modifier.get(i).getDisplayName() + " x"
+ + modifier.get(i).stackSize);
+ }
+ }
+
+ /**
+ * @param stack
+ * @param player
+ */
+ public void action(ItemStack item, EntityPlayer player) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.action(item, player, this);
+ }
+
+ /**
+ * @param item
+ * @param player
+ * @param source
+ * @return
+ */
+ public boolean onPlayerAttackedCacellable(ItemStack item,
+ EntityPlayer player, DamageSource source, float amount) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ return mod.onPlayerAttackedCancellable(item, player,
+ source, this, amount);
+ return false;
+ }
+
+ /**
+ * @param item
+ * @param player
+ * @param target
+ * @return
+ */
+ public boolean onEntityAttackedCacellable(ItemStack item,
+ EntityPlayer player, Entity target, float amount) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ return mod.onEntityAttackedCancellable(item, player,
+ target, this, amount);
+ return false;
+ }
+
+ /**
+ * @param item
+ * @param player
+ * @param source
+ * @return
+ */
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player,
+ DamageSource source, float amount) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onPlayerAttacked(item, player, source, this, amount);
+ }
+
+ /**
+ * @param item
+ * @param player
+ * @param target
+ * @return
+ */
+ public void onEntityAttacked(ItemStack item, EntityPlayer player,
+ Entity target, float amount) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onEntityAttacked(item, player, target, this, amount);
+ }
+
+ public void onPlayerDead(ItemStack item, EntityPlayer player,
+ DamageSource source) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onPlayerDead(item, player, source, this);
+ }
+
+ public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onPlayerRespawn(item, event, this);
+ }
+
+ public void onJewelryEquipped(ItemStack item) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onJewelryEquipped(item, this);
+ }
+
+ public void onJewelryUnequipped(ItemStack item) {
+ for (ModifierEffects mod : ModifierEffects.getEffects())
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier()))
+ mod.onJewelryUnequipped(item, this);
+ }
}
|
