diff options
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java')
| -rwxr-xr-x | src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java | 203 |
1 files changed, 136 insertions, 67 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java index b14a365..8b477c6 100755 --- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -6,10 +6,10 @@ import java.util.List; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.affixes.AffixMods;
import darkknight.jewelrycraft.api.IJewelryItem;
import darkknight.jewelrycraft.api.ModifierEffect;
import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.effects.AffixMods;
import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.Variables;
@@ -20,6 +20,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import net.minecraftforge.event.entity.living.LivingAttackEvent;
+import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -75,15 +77,18 @@ public abstract class ItemBaseJewelry extends Item { String prefix = JewelryNBT.prefix(stack);
String suffix = JewelryNBT.suffix(stack);
-
+
if (prefix != null && !prefix.equals("")) {
- baseName = prefix + " " + baseName;
+ String translatedPrefix = StatCollector.translateToLocal("prefix." + Variables.MODID + "." + prefix);
+ baseName = translatedPrefix + " " + baseName;
}
-
+
if (suffix != null && !suffix.equals("")) {
- baseName = baseName + " of " + suffix;
+ String translatedSuffix = StatCollector.translateToLocal("suffix." + Variables.MODID + "." + suffix);
+
+ baseName = baseName + " " + translatedSuffix;
}
-
+
return baseName;
}
@@ -114,14 +119,39 @@ public abstract class ItemBaseJewelry extends Item { + EnumChatFormatting.BLUE + gem.getDisplayName());
}
- ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
+ if (player.isSneaking()) {
+ ArrayList<ItemStack> modifier = JewelryNBT.modifier(stack);
- if (!modifier.isEmpty()) {
- list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": ");
- }
+ if (!modifier.isEmpty()) {
+ list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": ");
+ }
+
+ for (ItemStack is : modifier) {
+ list.add(EnumChatFormatting.DARK_PURPLE + is.getDisplayName() + " x" + is.stackSize);
+ }
- for (ItemStack is : modifier) {
- list.add(EnumChatFormatting.DARK_PURPLE + is.getDisplayName() + " x" + is.stackSize);
+ String prefix = JewelryNBT.prefix(stack);
+ String suffix = JewelryNBT.suffix(stack);
+
+ if (prefix != null && !prefix.equals("")) {
+ String translatedPrefix = StatCollector
+ .translateToLocal("prefix." + Variables.MODID + "." + prefix);
+ String translatedDesc = StatCollector
+ .translateToLocal("prefix." + Variables.MODID + "." + prefix + ".desc");
+
+ list.add(translatedPrefix + ": " + translatedDesc);
+ }
+
+ if (suffix != null && !suffix.equals("")) {
+ String translatedSuffix = StatCollector
+ .translateToLocal("suffix." + Variables.MODID + "." + prefix);
+ String translatedDesc = StatCollector
+ .translateToLocal("suffix." + Variables.MODID + "." + prefix + ".desc");
+
+ list.add(translatedSuffix + ": " + translatedDesc);
+ }
+ } else {
+ list.add("<Sneak to see modifier info>");
}
}
}
@@ -136,12 +166,14 @@ public abstract class ItemBaseJewelry extends Item { mod.action(item, player, this);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.action(item, player, this);
- if (suffix != null) suffix.action(item, player, this);
+
+ if (prefix != null)
+ prefix.action(item, player, this);
+ if (suffix != null)
+ suffix.action(item, player, this);
}
/**
@@ -152,30 +184,33 @@ public abstract class ItemBaseJewelry extends Item { */
public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) {
boolean cancelEvent = false;
-
+
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
cancelEvent = mod.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
+
if (prefix != null) {
cancelEvent = prefix.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
-
+
if (suffix != null) {
cancelEvent = suffix.onPlayerAttackedCancellable(item, player, source, this, amount);
-
- if (cancelEvent) return true;
+
+ if (cancelEvent)
+ return true;
}
-
+
return cancelEvent;
}
@@ -185,32 +220,36 @@ public abstract class ItemBaseJewelry extends Item { * @param target
* @return
*/
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) {
+ public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target,
+ LivingAttackEvent event) {
boolean cancelEvent = false;
-
+
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- cancelEvent = mod.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = mod.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
+
if (prefix != null) {
- cancelEvent = prefix.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = prefix.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
-
+
if (suffix != null) {
- cancelEvent = suffix.onEntityAttackedCancellable(item, player, target, this, amount);
-
- if (cancelEvent) return true;
+ cancelEvent = suffix.onEntityAttackedCancellable(item, player, target, this, event);
+
+ if (cancelEvent)
+ return true;
}
-
+
return cancelEvent;
}
@@ -226,12 +265,14 @@ public abstract class ItemBaseJewelry extends Item { mod.onPlayerAttacked(item, player, source, this, amount);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerAttacked(item, player, source, this, amount);
- if (suffix != null) suffix.onPlayerAttacked(item, player, source, this, amount);
+
+ if (prefix != null)
+ prefix.onPlayerAttacked(item, player, source, this, amount);
+ if (suffix != null)
+ suffix.onPlayerAttacked(item, player, source, this, amount);
}
/**
@@ -240,18 +281,20 @@ public abstract class ItemBaseJewelry extends Item { * @param target
* @return
*/
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) {
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, LivingAttackEvent event) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onEntityAttacked(item, player, target, this, amount);
+ mod.onEntityAttacked(item, player, target, this, event);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onEntityAttacked(item, player, target, this, amount);
- if (suffix != null) suffix.onEntityAttacked(item, player, target, this, amount);
+
+ if (prefix != null)
+ prefix.onEntityAttacked(item, player, target, this, event);
+ if (suffix != null)
+ suffix.onEntityAttacked(item, player, target, this, event);
}
public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source) {
@@ -263,9 +306,11 @@ public abstract class ItemBaseJewelry extends Item { ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerDead(item, player, source, this);
- if (suffix != null) suffix.onPlayerDead(item, player, source, this);
+
+ if (prefix != null)
+ prefix.onPlayerDead(item, player, source, this);
+ if (suffix != null)
+ suffix.onPlayerDead(item, player, source, this);
}
public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event) {
@@ -277,36 +322,60 @@ public abstract class ItemBaseJewelry extends Item { ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onPlayerRespawn(item, event, this);
- if (suffix != null) suffix.onPlayerRespawn(item, event, this);
+
+ if (prefix != null)
+ prefix.onPlayerRespawn(item, event, this);
+ if (suffix != null)
+ suffix.onPlayerRespawn(item, event, this);
}
- public void onJewelryEquipped(ItemStack item) {
+ public void onJewelryEquipped(ItemStack item, EntityPlayer player) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onJewelryEquipped(item, this);
+ mod.onJewelryEquipped(item, this, player);
}
}
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onJewelryEquipped(item, this);
- if (suffix != null) suffix.onJewelryEquipped(item, this);
+
+ if (prefix != null)
+ prefix.onJewelryEquipped(item, this, player);
+ if (suffix != null)
+ suffix.onJewelryEquipped(item, this, player);
}
- public void onJewelryUnequipped(ItemStack item) {
+ public void onJewelryUnequipped(ItemStack item, EntityPlayer player) {
for (ModifierEffect mod : ModifierEffect.getEffects()) {
if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
- mod.onJewelryUnequipped(item, this);
+ mod.onJewelryUnequipped(item, this, player);
}
}
-
+
ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
-
- if (prefix != null) prefix.onJewelryUnequipped(item, this);
- if (suffix != null) suffix.onJewelryUnequipped(item, this);
+
+ if (prefix != null)
+ prefix.onJewelryUnequipped(item, this, player);
+
+ if (suffix != null)
+ suffix.onJewelryUnequipped(item, this, player);
+ }
+
+ public void onLivingDropItems(ItemStack item, EntityPlayer player, LivingDropsEvent event) {
+ for (ModifierEffect mod : ModifierEffect.getEffects()) {
+ if (JewelryNBT.doesModifierExist(item, mod.getModifier())) {
+ mod.onLivingDropItems(item, player, event, this);
+ }
+ }
+
+ ModifierEffect prefix = AffixMods.getPrefix(JewelryNBT.prefix(item));
+ ModifierEffect suffix = AffixMods.getSuffix(JewelryNBT.suffix(item));
+
+ if (prefix != null)
+ prefix.onLivingDropItems(item, player, event, this);
+
+ if (suffix != null)
+ suffix.onLivingDropItems(item, player, event, this);
}
}
\ No newline at end of file |
