summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java')
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/effects/EffectFeather.java123
1 files changed, 31 insertions, 92 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
index 5235b7d..42df76f 100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
@@ -22,11 +22,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.DamageSource;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.StatCollector;
+import net.minecraft.util.*;
public class EffectFeather extends ModifierEffects {
public EffectFeather() {
@@ -34,29 +30,17 @@ public class EffectFeather extends ModifierEffects {
}
@Override
- public void action(ItemStack item, EntityPlayer player,
- Item jewelry) {
+ public void action(ItemStack item, EntityPlayer player, Item jewelry) {
// Positive earrings
if (jewelry instanceof ItemEarrings) {
- AxisAlignedBB axisalignedbb = player.boundingBox
- .expand(1.0D, 1.0D, 1.0D);
- List<?> list = player.worldObj
- .getEntitiesWithinAABB(
- EntityArrow.class,
- axisalignedbb);
- if (!player.worldObj.isRemote && list != null
- && !list.isEmpty()) {
+ AxisAlignedBB axisalignedbb = player.boundingBox.expand(1.0D, 1.0D, 1.0D);
+ List<?> list = player.worldObj.getEntitiesWithinAABB(EntityArrow.class, axisalignedbb);
+ if (!player.worldObj.isRemote && list != null && !list.isEmpty()) {
Iterator<?> iterator = list.iterator();
while (iterator.hasNext()) {
- EntityArrow arrow = (EntityArrow) iterator
- .next();
- if ((arrow.shootingEntity == null
- || !(arrow.shootingEntity
- .equals(player))
- || arrow.canBePickedUp == 0)
- && rand.nextInt(2
- + JewelryNBT.numberOfModifiers(
- item)) == 0)
+ EntityArrow arrow = (EntityArrow) iterator.next();
+ if ((arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player))
+ || arrow.canBePickedUp == 0) && rand.nextInt(2 + JewelryNBT.numberOfModifiers(item)) == 0)
arrow.setDead();
}
}
@@ -64,59 +48,31 @@ public class EffectFeather extends ModifierEffects {
if (jewelry instanceof ItemBracelet) {
// Positive bracelet
if (player.motionY < 0)
- player.motionY *= (0.6D + (JewelryNBT
- .numberOfModifiers(item)
- - 1) * 0.03D);
- if (rand.nextInt(JewelryNBT
- .numberOfModifiers(item)) == 0)
+ player.motionY *= (0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.03D);
+ if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
player.fallDistance = 0F;
// Negative bracelet
if (!player.isPotionActive(Potion.moveSlowdown)
- || player.getActivePotionEffect(
- Potion.moveSlowdown)
- .getDuration() < 30)
- player.addPotionEffect(new PotionEffect(
- Potion.moveSlowdown.id,
- 80 + JewelryNBT.numberOfModifiers(
- item) * 10,
- 1 + JewelryNBT.numberOfModifiers(
- item)
- / 4));
+ || player.getActivePotionEffect(Potion.moveSlowdown).getDuration() < 30)
+ player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id,
+ 80 + JewelryNBT.numberOfModifiers(item) * 10, 1 + JewelryNBT.numberOfModifiers(item) / 4));
}
}
@Override
- public boolean onEntityAttackedCancellable(ItemStack item,
- EntityPlayer player, Entity target, Item jewelry,
+ public boolean onEntityAttackedCancellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry,
float amount) {
NBTTagCompound enemyData = target.getEntityData();
- if (jewelry instanceof ItemRing
- && !player.worldObj.isRemote) {
+ if (jewelry instanceof ItemRing && !player.worldObj.isRemote) {
if (enemyData.getInteger("reAttacked") == 0) {
// Negative ring
- enemyData.setInteger("reAttacked",
- enemyData.getInteger(
- "reAttacked")
- + 1);
- target.attackEntityFrom(DamageSource
- .causePlayerDamage(player),
- amount / (2F + (JewelryNBT
- .numberOfModifiers(
- item)
- - 1)
- * 0.3F));
+ enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
+ target.attackEntityFrom(DamageSource.causePlayerDamage(player),
+ amount / (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.3F));
// Positive ring
- if (rand.nextInt(2) == 0
- && target instanceof EntityLivingBase)
- ((EntityLivingBase) target)
- .addPotionEffect(
- new PotionEffect(
- PotionList.stun.id,
- (51 - JewelryNBT.numberOfModifiers(
- item))
- * 2,
- 0,
- false));
+ if (rand.nextInt(2) == 0 && target instanceof EntityLivingBase)
+ ((EntityLivingBase) target).addPotionEffect(new PotionEffect(PotionList.stun.id,
+ (51 - JewelryNBT.numberOfModifiers(item)) * 2, 0, false));
return true;
}
enemyData.setInteger("reAttacked", 0);
@@ -125,43 +81,26 @@ public class EffectFeather extends ModifierEffects {
}
@Override
- public boolean onPlayerAttackedCancellable(ItemStack item,
- EntityPlayer player, DamageSource source,
- Item jewelry, float amount) {
+ public boolean onPlayerAttackedCancellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry,
+ float amount) {
// Positive necklace
- if (jewelry instanceof ItemNecklace && rand.nextInt(3
- + JewelryNBT.numberOfModifiers(item)) == 0
- && source != DamageSourceList.weak
- && source != DamageSource.inFire
- && source != DamageSource.onFire
+ if (jewelry instanceof ItemNecklace && rand.nextInt(3 + JewelryNBT.numberOfModifiers(item)) == 0
+ && source != DamageSourceList.weak && source != DamageSource.inFire && source != DamageSource.onFire
&& source != DamageSource.lava) {
- player.addChatComponentMessage(
- new ChatComponentText(
- EnumChatFormatting.GRAY
- + StatCollector.translateToLocal(
- "chatmessage." + Variables.MODID
- + ".effect.feather")));
+ player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY
+ + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.feather")));
return true;
}
// Negative necklace
if (jewelry instanceof ItemNecklace
- && (source == DamageSource.inFire
- || source == DamageSource.onFire
- || source == DamageSource.lava)
+ && (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava)
&& source != DamageSourceList.weak)
player.attackEntityFrom(DamageSourceList.weak,
- amount * (3F + (JewelryNBT
- .numberOfModifiers(
- item)
- - 1) * 0.1F));
+ amount * (3F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
// Negative earrings
- if (jewelry instanceof ItemEarrings
- && source.damageType.equals("arrow"))
+ if (jewelry instanceof ItemEarrings && source.damageType.equals("arrow"))
player.attackEntityFrom(DamageSourceList.weak,
- amount * (2F + (JewelryNBT
- .numberOfModifiers(
- item)
- - 1) * 0.1F));
+ amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
return false;
}
}