summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-05 01:53:14 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-05 01:53:14 +0100
commita6a3bfa6f313adba5afe6eb4a0da049a8d641cfc (patch)
tree56da97ba430232a7d0da51a3b8b9f444d96325c7 /src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
parent40487f07fa5ef31fde99713c0b842d34a0ba3622 (diff)
Stuff!
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java')
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java201
1 files changed, 99 insertions, 102 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
index 68c502d..cf409b2 100644
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
@@ -1,102 +1,99 @@
-package darkknight.jewelrycraft.effects;
-
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.potion.Potion;
-import net.minecraft.potion.PotionEffect;
-import net.minecraft.util.DamageSource;
-import darkknight.jewelrycraft.api.ModifierEffects;
-import darkknight.jewelrycraft.damage.DamageSourceList;
-import darkknight.jewelrycraft.item.ItemBracelet;
-import darkknight.jewelrycraft.item.ItemEarrings;
-import darkknight.jewelrycraft.item.ItemNecklace;
-import darkknight.jewelrycraft.item.ItemRing;
-import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.PlayerUtils;
-import darkknight.jewelrycraft.util.Variables;
-
-public class EffectObsidian extends ModifierEffects
-{
- public EffectObsidian()
- {
- super(new ItemStack(Blocks.obsidian));
- }
-
- @Override
- public void action(ItemStack item, EntityPlayer player, Item jewelry)
- {
- boolean exists = JewelryNBT.doesModifierExist(item, modifier);
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (jewelry instanceof ItemNecklace && exists){
- // Positive necklace
- player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, 2, true));
- // Negative necklace
- if (player.isInWater() && !player.capabilities.isCreativeMode){
- double slowAmount = 0.2D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D;
- player.motionX *= slowAmount;
- player.motionY *= slowAmount;
- player.motionZ *= slowAmount;
- player.motionY = -0.5D;
- if (rand.nextInt(50) == 0) player.attackEntityFrom(DamageSourceList.weak, 2F);
- }
- }
- // Negative bracelet
- if (jewelry instanceof ItemBracelet && exists && playerInfo.hasKey("falls") && playerInfo.getInteger("falls") >= 300) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1, true));
- // Negative ring
- if (jewelry instanceof ItemRing && exists && playerInfo.hasKey("strikes") && playerInfo.getInteger("strikes") >= 200){
- player.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 0, true));
- player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60, 1, true));
- }
- }
-
- @Override
- public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
- {
- boolean exists = JewelryNBT.doesModifierExist(item, modifier);
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- if (jewelry instanceof ItemEarrings && exists && (source == DamageSource.anvil || source.damageType.equals("arrow"))){
- if (playerInfo.hasKey("protected")) playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1);
- else playerInfo.setInteger("protected", 1);
- // Positive && Negative earrings
- if (playerInfo.getInteger("protected") < 200) playerInfo.setBoolean("negateDamage", true);
- else player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F);
- }
- if (jewelry instanceof ItemBracelet && exists && source == DamageSource.fall){
- if (playerInfo.hasKey("falls")) playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1);
- else playerInfo.setInteger("falls", 1);
- // Positive bracelet
- if (playerInfo.getInteger("falls") < 300) playerInfo.setBoolean("negateDamage", true);
- }
- }
-
- public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry)
- {
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- playerInfo.setInteger("falls", 0);
- playerInfo.setInteger("strikes", 0);
- playerInfo.setInteger("protected", 0);
- }
-
- public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
- {
- boolean exists = JewelryNBT.doesModifierExist(item, modifier);
- NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
- NBTTagCompound enemyData = target.getEntityData();
- // Positive ring
- if (jewelry instanceof ItemRing && exists && playerInfo.getInteger("strikes") < 200 && !player.worldObj.isRemote){
- if (enemyData.getInteger("reAttacked") == 0){
- if (playerInfo.hasKey("strikes")) playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1);
- else playerInfo.setInteger("strikes", 1);
- // Negative ring
- enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
- target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 2F);
- playerInfo.setBoolean("weakDamage", true);
- }
- if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
- }
- }
-}
+package darkknight.jewelrycraft.effects;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import net.minecraft.util.DamageSource;
+import darkknight.jewelrycraft.api.ModifierEffects;
+import darkknight.jewelrycraft.damage.DamageSourceList;
+import darkknight.jewelrycraft.item.ItemBracelet;
+import darkknight.jewelrycraft.item.ItemEarrings;
+import darkknight.jewelrycraft.item.ItemNecklace;
+import darkknight.jewelrycraft.item.ItemRing;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
+
+public class EffectObsidian extends ModifierEffects
+{
+ public EffectObsidian()
+ {
+ super(new ItemStack(Blocks.obsidian));
+ }
+
+ @Override
+ public void action(ItemStack item, EntityPlayer player, Item jewelry)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (jewelry instanceof ItemNecklace){
+ // Positive necklace
+ player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, 2, true));
+ // Negative necklace
+ if (player.isInWater() && !player.capabilities.isCreativeMode){
+ double slowAmount = 0.2D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D;
+ player.motionX *= slowAmount;
+ player.motionY *= slowAmount;
+ player.motionZ *= slowAmount;
+ player.motionY = -0.5D;
+ if (rand.nextInt(50) == 0) player.attackEntityFrom(DamageSourceList.weak, 2F);
+ }
+ }
+ // Negative bracelet
+ if (jewelry instanceof ItemBracelet && playerInfo.hasKey("falls") && playerInfo.getInteger("falls") >= 300) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1, true));
+ // Negative ring
+ if (jewelry instanceof ItemRing && playerInfo.hasKey("strikes") && playerInfo.getInteger("strikes") >= 200){
+ player.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 0, true));
+ player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60, 1, true));
+ }
+ }
+
+ @Override
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (jewelry instanceof ItemEarrings && (source == DamageSource.anvil || source.damageType.equals("arrow"))){
+ if (playerInfo.hasKey("protected")) playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1);
+ else playerInfo.setInteger("protected", 1);
+ // Positive && Negative earrings
+ if (playerInfo.getInteger("protected") < 200) playerInfo.setBoolean("negateDamage", true);
+ else player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F);
+ }
+ if (jewelry instanceof ItemBracelet && source == DamageSource.fall){
+ if (playerInfo.hasKey("falls")) playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1);
+ else playerInfo.setInteger("falls", 1);
+ // Positive bracelet
+ if (playerInfo.getInteger("falls") < 300) playerInfo.setBoolean("negateDamage", true);
+ }
+ }
+
+ public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ playerInfo.setInteger("falls", 0);
+ playerInfo.setInteger("strikes", 0);
+ playerInfo.setInteger("protected", 0);
+ }
+
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ NBTTagCompound enemyData = target.getEntityData();
+ // Positive ring
+ if (jewelry instanceof ItemRing && playerInfo.getInteger("strikes") < 200 && !player.worldObj.isRemote){
+ if (enemyData.getInteger("reAttacked") == 0){
+ if (playerInfo.hasKey("strikes")) playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1);
+ else playerInfo.setInteger("strikes", 1);
+ // Negative ring
+ enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
+ target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 2F);
+ playerInfo.setBoolean("weakDamage", true);
+ }
+ if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
+ }
+ }
+}