diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-08-22 20:01:40 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2019-08-22 20:01:40 -0400 |
| commit | 20bef6e26d948698398bd16aeab8c9e6b89110e4 (patch) | |
| tree | 8a21e17f78b330435f4ce2d4355d72b773230aa7 /src/main/java/darkknight/jewelrycraft/effects | |
| parent | 26fb28edd1ebb6390f8803fed3876d222cb8fdba (diff) | |
Format/import cleanup
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects')
6 files changed, 162 insertions, 457 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java index ebfa48c..f65d135 100755 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java @@ -21,32 +21,22 @@ public class EffectBlazePowder extends ModifierEffects { }
@Override
- public void action(ItemStack item, EntityPlayer player,
- Item jewelry) {
+ public void action(ItemStack item, EntityPlayer player, Item jewelry) {
if (jewelry instanceof ItemNecklace) {
// Positive for necklace
- if (player.isBurning() && rand.nextInt(JewelryNBT
- .numberOfModifiers(item)) == 0)
+ if (player.isBurning() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
player.extinguish();
// Negative for necklace
if (player.isInWater())
- player.attackEntityFrom(DamageSource.drown,
- 1f + (JewelryNBT.numberOfModifiers(
- item) - 1)
- * 0.1F);
+ player.attackEntityFrom(DamageSource.drown, 1f + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F);
}
// Negative for bracelet
- if (jewelry instanceof ItemBracelet
- && player.isInWater()) {
- double slowAmount = 0.6D + (JewelryNBT
- .numberOfModifiers(item) - 1)
- * 0.05D;
+ if (jewelry instanceof ItemBracelet && player.isInWater()) {
+ double slowAmount = 0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D;
player.motionX *= slowAmount;
player.motionY *= slowAmount;
player.motionZ *= slowAmount;
- player.motionY -= (0.02D + (JewelryNBT
- .numberOfModifiers(item) - 1)
- * 0.005D);
+ player.motionY -= (0.02D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D);
if (player.isCollidedHorizontally)
player.motionY = 0.30000001192092896D;
}
@@ -55,67 +45,41 @@ public class EffectBlazePowder extends ModifierEffects { if (player.getAir() >= 300)
player.setAir(player.getAir() / 2);
else
- player.setAir(player.getAir() - JewelryNBT
- .numberOfModifiers(item));
+ player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item));
}
}
@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) {
// Balanced for ring
- if (jewelry instanceof ItemRing && !player.isInWater()
- && rand.nextInt(JewelryNBT
- .numberOfModifiers(
- item)) == 0)
+ if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
target.setFire(2);
return false;
}
@Override
- public boolean onPlayerAttackedCancellable(ItemStack item,
- EntityPlayer player, DamageSource source,
- Item jewelry, float amount) {
- if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0
- && source == DamageSource.lava
- || source == DamageSource.inFire
- || source == DamageSource.onFire) {
+ public boolean onPlayerAttackedCancellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry,
+ float amount) {
+ if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0 && source == DamageSource.lava
+ || source == DamageSource.inFire || source == DamageSource.onFire) {
// Positive for earrings
- int stackSize = JewelryNBT.modifierSize(item,
- modifier);
+ int stackSize = JewelryNBT.modifierSize(item, modifier);
- player.heal(stackSize * 0.05F - (JewelryNBT
- .numberOfModifiers(item) - 1)
- * 0.01F);
+ player.heal(stackSize * 0.05F - (JewelryNBT.numberOfModifiers(item) - 1) * 0.01F);
return true;
}
// Positive for bracelet
if (jewelry instanceof ItemBracelet)
- if (source == DamageSource.inFire
- || source == DamageSource.onFire
+ if (source == DamageSource.inFire || source == DamageSource.onFire
|| source == DamageSource.lava
- && player.worldObj
- .isMaterialInBB(AxisAlignedBB
- .getBoundingBox(player.boundingBox.minX,
- player.boundingBox.minY,
- player.boundingBox.minZ,
- player.boundingBox.maxX,
- player.boundingBox.maxY
- - 0.7,
- player.boundingBox.maxZ),
- Material.lava)
- && !player.worldObj
- .isMaterialInBB(AxisAlignedBB
- .getBoundingBox(player.boundingBox.minX,
- player.boundingBox.minY
- + 0.9,
- player.boundingBox.minZ,
- player.boundingBox.maxX,
- player.boundingBox.maxY,
- player.boundingBox.maxZ),
- Material.lava)) {
+ && player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX,
+ player.boundingBox.minY, player.boundingBox.minZ, player.boundingBox.maxX,
+ player.boundingBox.maxY - 0.7, player.boundingBox.maxZ), Material.lava)
+ && !player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX,
+ player.boundingBox.minY + 0.9, player.boundingBox.minZ, player.boundingBox.maxX,
+ player.boundingBox.maxY, player.boundingBox.maxZ), Material.lava)) {
return true;
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java index 4f24e8f..1f0c325 100755 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java @@ -19,11 +19,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.ChatComponentText;
-import net.minecraft.util.DamageSource;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.StatCollector;
-import net.minecraft.util.Vec3;
+import net.minecraft.util.*;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.biome.BiomeGenBase;
@@ -40,8 +36,7 @@ public class EffectEnderEye extends ModifierEffects { if (Minecraft.getMinecraft().gameSettings.renderDistanceChunks <= 2) {
viewDistance = 10;
} else {
- viewDistance = Minecraft
- .getMinecraft().gameSettings.renderDistanceChunks;
+ viewDistance = Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
}
setViewDistance(item, viewDistance);
@@ -51,185 +46,93 @@ public class EffectEnderEye extends ModifierEffects { @Override
public void onJewelryUnequipped(ItemStack item, Item jewelry) {
if (jewelry instanceof ItemRing)
- Minecraft.getMinecraft().gameSettings
- .setOptionFloatValue(
- Options.RENDER_DISTANCE,
- getViewDistance(item));
+ Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, getViewDistance(item));
}
@SuppressWarnings("cast")
@Override
- public void action(ItemStack item, EntityPlayer player,
- Item jewelry) {
- if (jewelry instanceof ItemEarrings
- && !player.worldObj.isRemote) {
- for (Object e : player.worldObj
- .getEntitiesWithinAABB(
- EntityEnderman.class,
- player.boundingBox
- .expand(100D, 0D,
- 100D))) {
+ public void action(ItemStack item, EntityPlayer player, Item jewelry) {
+ if (jewelry instanceof ItemEarrings && !player.worldObj.isRemote) {
+ for (Object e : player.worldObj.getEntitiesWithinAABB(EntityEnderman.class,
+ player.boundingBox.expand(100D, 0D, 100D))) {
EntityEnderman enderman = (EntityEnderman) e;
- ReflectionHelper.setPrivateValue(
- EntityEnderman.class,
- enderman, -1, "stareTimer",
- "field_70826_g");
+ ReflectionHelper.setPrivateValue(EntityEnderman.class, enderman, -1, "stareTimer", "field_70826_g");
- Vec3 vec3 = player.getLook(1.0F)
- .normalize();
- Vec3 vec31 = Vec3.createVectorHelper(
- enderman.posX - player.posX,
- enderman.boundingBox.minY
- + (double) (enderman.height
- / 2.0F)
- - (player.posY + (double) player
- .getEyeHeight()),
+ Vec3 vec3 = player.getLook(1.0F).normalize();
+ Vec3 vec31 = Vec3.createVectorHelper(enderman.posX - player.posX, enderman.boundingBox.minY
+ + (double) (enderman.height / 2.0F) - (player.posY + (double) player.getEyeHeight()),
enderman.posZ - player.posZ);
double d0 = vec31.lengthVector();
vec31 = vec31.normalize();
double d1 = vec3.dotProduct(vec31);
- if (d1 > 1.0D - 0.025D / d0
- && player.canEntityBeSeen(
- enderman)) {
+ if (d1 > 1.0D - 0.025D / d0 && player.canEntityBeSeen(enderman)) {
// Positive earrings
- if (rand.nextInt(JewelryNBT
- .numberOfModifiers(
- item)) == 0)
+ if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
enderman.setTarget(null);
// Negative earrings
- if (!player.isPotionActive(
- Potion.confusion)
- || player.getActivePotionEffect(
- Potion.confusion)
- .getDuration() <= 80)
+ if (!player.isPotionActive(Potion.confusion)
+ || player.getActivePotionEffect(Potion.confusion).getDuration() <= 80)
player.addPotionEffect(
- new PotionEffect(
- Potion.confusion.id,
- 300,
- 2 + JewelryNBT.numberOfModifiers(
- item)
- / 4));
+ new PotionEffect(Potion.confusion.id, 300, 2 + JewelryNBT.numberOfModifiers(item) / 4));
}
}
}
// Positive necklace
- if (jewelry instanceof ItemNecklace
- && !player.worldObj.isRemote) {
- ChunkPosition chunkposition = player.worldObj
- .findClosestStructure("Stronghold",
- (int) player.posX,
- (int) player.posY,
- (int) player.posZ);
+ if (jewelry instanceof ItemNecklace && !player.worldObj.isRemote) {
+ ChunkPosition chunkposition = player.worldObj.findClosestStructure("Stronghold", (int) player.posX,
+ (int) player.posY, (int) player.posZ);
if (chunkposition != null) {
Minecraft.getMinecraft().thePlayer.motionX += 0.01D
- * Math.signum((double) chunkposition.chunkPosX
- - player.posX)
- * (rand.nextInt(JewelryNBT
- .numberOfModifiers(
- item)) == 0 ? 1
- : -1);
+ * Math.signum((double) chunkposition.chunkPosX - player.posX)
+ * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1);
Minecraft.getMinecraft().thePlayer.motionZ += 0.01D
- * Math.signum((double) chunkposition.chunkPosZ
- - player.posZ)
- * (rand.nextInt(JewelryNBT
- .numberOfModifiers(
- item)) == 0 ? 1
- : -1);
+ * Math.signum((double) chunkposition.chunkPosZ - player.posZ)
+ * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1);
}
}
// Positive bracelet
- if (jewelry instanceof ItemBracelet
- && !player.worldObj.isRemote
- && player.worldObj.getBiomeGenForCoords(
- (int) player.posX,
- (int) player.posZ) == BiomeGenBase.sky
- && (!player.isPotionActive(
- Potion.moveSpeed)
- || player.getActivePotionEffect(
- Potion.moveSpeed)
- .getDuration() < 30))
- player.addPotionEffect(new PotionEffect(
- Potion.moveSpeed.id,
- 150 - JewelryNBT.numberOfModifiers(
- item) * 10,
- 2 - JewelryNBT.numberOfModifiers(
- item) / 5));
+ if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote
+ && player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ) == BiomeGenBase.sky
+ && (!player.isPotionActive(Potion.moveSpeed)
+ || player.getActivePotionEffect(Potion.moveSpeed).getDuration() < 30))
+ player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 150 - JewelryNBT.numberOfModifiers(item) * 10,
+ 2 - JewelryNBT.numberOfModifiers(item) / 5));
// Negative bracelet
- if (jewelry instanceof ItemBracelet
- && !player.worldObj.isRemote
- && rand.nextInt(520 - JewelryNBT
- .numberOfModifiers(item)
- * 20) == 15)
- player.setPositionAndUpdate(player.posX + rand
- .nextInt(30)
- * (rand.nextBoolean() ? -1 : 1),
- player.posY,
- player.posZ + rand.nextInt(30)
- * (rand.nextBoolean()
- ? -1
- : 1));
+ if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote
+ && rand.nextInt(520 - JewelryNBT.numberOfModifiers(item) * 20) == 15)
+ player.setPositionAndUpdate(player.posX + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1), player.posY,
+ player.posZ + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1));
// Negative ring
- if (jewelry instanceof ItemRing && Minecraft
- .getMinecraft().gameSettings.renderDistanceChunks != 2.2F
- - JewelryNBT.numberOfModifiers(
- item)
- * 0.1F)
- Minecraft.getMinecraft().gameSettings
- .setOptionFloatValue(
- Options.RENDER_DISTANCE,
- 2.2F - JewelryNBT
- .numberOfModifiers(
- item)
- * 0.1F);
+ if (jewelry instanceof ItemRing && Minecraft.getMinecraft().gameSettings.renderDistanceChunks != 2.2F
+ - JewelryNBT.numberOfModifiers(item) * 0.1F)
+ Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE,
+ 2.2F - JewelryNBT.numberOfModifiers(item) * 0.1F);
// Positive ring
- if (jewelry instanceof ItemRing && rand.nextInt(
- 180 + JewelryNBT.numberOfModifiers(item)
- * 20) == 12) {
- for (int i = (int) player.posX
- - 2; i <= (int) player.posX
- + 2; i++)
- for (int j = (int) player.posY
- - 2; j <= (int) player.posY
- + 2; j++)
- for (int k = (int) player.posZ
- - 2; k <= (int) player.posZ
- + 2; k++)
- if (player.worldObj
- .getBlock(i, j, k) instanceof BlockOre)
- player.addChatComponentMessage(
- new ChatComponentText(
- EnumChatFormatting.GRAY
- + StatCollector.translateToLocal(
- "chatmessage." + Variables.MODID
- + ".effect.endereye.1")
- + " "
- + player.worldObj
- .getBlock(i, j, k)
- .getLocalizedName()
- + " "
- + StatCollector.translateToLocal(
- "chatmessage." + Variables.MODID
- + ".effect.endereye.2")));
+ if (jewelry instanceof ItemRing && rand.nextInt(180 + JewelryNBT.numberOfModifiers(item) * 20) == 12) {
+ for (int i = (int) player.posX - 2; i <= (int) player.posX + 2; i++)
+ for (int j = (int) player.posY - 2; j <= (int) player.posY + 2; j++)
+ for (int k = (int) player.posZ - 2; k <= (int) player.posZ + 2; k++)
+ if (player.worldObj.getBlock(i, j, k) instanceof BlockOre)
+ player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY
+ + StatCollector
+ .translateToLocal("chatmessage." + Variables.MODID + ".effect.endereye.1")
+ + " " + player.worldObj.getBlock(i, j, k).getLocalizedName() + " "
+ + StatCollector.translateToLocal(
+ "chatmessage." + Variables.MODID + ".effect.endereye.2")));
}
}
@Override
- public void onPlayerAttacked(ItemStack item, EntityPlayer player,
- DamageSource source, Item jewelry, float amount) {
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) {
// Negative necklace
- if (jewelry instanceof ItemNecklace
- && !player.worldObj.isRemote)
- player.addPotionEffect(new PotionEffect(
- Potion.blindness.id,
- 100 + JewelryNBT.numberOfModifiers(
- item) * 30,
- 1));
+ if (jewelry instanceof ItemNecklace && !player.worldObj.isRemote)
+ player.addPotionEffect(
+ new PotionEffect(Potion.blindness.id, 100 + JewelryNBT.numberOfModifiers(item) * 30, 1));
}
- public static void setViewDistance(ItemStack item,
- int viewDistance) {
+ public static void setViewDistance(ItemStack item, int viewDistance) {
NBTTagCompound itemStackData;
if (item.hasTagCompound())
itemStackData = item.getTagCompound();
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java index 562d83e..7722484 100755 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java @@ -27,119 +27,70 @@ public class EffectEnderPearl extends ModifierEffects { }
@Override
- public void action(ItemStack item, EntityPlayer player,
- Item jewelry) {
+ public void action(ItemStack item, EntityPlayer player, Item jewelry) {
if (jewelry instanceof ItemEarrings) {
- AxisAlignedBB axisalignedbb = player.boundingBox
- .expand(2.0D, 2.0D, 2.0D);
- List<?> list = player.worldObj
- .getEntitiesWithinAABB(
- EntityArrow.class,
- axisalignedbb);
- if (!player.worldObj.isRemote && list != null
- && !list.isEmpty()) {
+ AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 2.0D, 2.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)))
+ EntityArrow arrow = (EntityArrow) iterator.next();
+ if (arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player)))
// Negative earrings
- if (rand.nextInt(
- 30) == 0) {
- arrow.worldObj.createExplosion(
- new EntityTNTPrimed(
- arrow.worldObj),
- arrow.posX,
- arrow.posY,
- arrow.posZ,
- 2F,
- true);
+ if (rand.nextInt(30) == 0) {
+ arrow.worldObj.createExplosion(new EntityTNTPrimed(arrow.worldObj), arrow.posX, arrow.posY,
+ arrow.posZ, 2F, true);
arrow.setDead();
}
// Positive earrings
else
- arrow.setPosition(
- arrow.posX + rand
- .nextInt(16)
- - rand.nextInt(16),
- arrow.posY + rand
- .nextInt(16),
- arrow.posZ + rand
- .nextInt(16)
- - rand.nextInt(16));
+ arrow.setPosition(arrow.posX + rand.nextInt(16) - rand.nextInt(16),
+ arrow.posY + rand.nextInt(16), arrow.posZ + rand.nextInt(16) - rand.nextInt(16));
}
}
}
// Negative Necklace
if (jewelry instanceof ItemNecklace)
- player.addPotionEffect(new PotionEffect(
- Potion.resistance.id, 60, -10,
- true));
+ player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, -10, true));
// Negative bracelet
if (jewelry instanceof ItemBracelet && player.isInWater())
- player.setPositionAndUpdate(
- player.posX + rand.nextInt(16)
- - rand.nextInt(16),
- player.posY + rand.nextInt(4),
- player.posZ + rand.nextInt(16)
- - rand.nextInt(16));
+ player.setPositionAndUpdate(player.posX + rand.nextInt(16) - rand.nextInt(16),
+ player.posY + rand.nextInt(4), player.posZ + rand.nextInt(16) - rand.nextInt(16));
}
@Override
- public void onPlayerAttacked(ItemStack item, EntityPlayer player,
- DamageSource source, Item jewelry, float amount) {
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) {
// Positive Necklace
- if (jewelry instanceof ItemNecklace
- && source.getEntity() != null)
- source.getEntity().attackEntityFrom(source,
- amount);
+ if (jewelry instanceof ItemNecklace && source.getEntity() != null)
+ source.getEntity().attackEntityFrom(source, amount);
// Positive bracelet
- if (jewelry instanceof ItemBracelet
- && !player.worldObj.isRemote) {
+ if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote) {
int id = player.worldObj.provider.dimensionId;
if (player.getHealth() <= 6F)
if (player.getBedLocation(id) != null)
- player.setPositionAndUpdate(player
- .getBedLocation(id).posX,
- player.getBedLocation(
- id).posY,
- player.getBedLocation(
- id).posZ);
+ player.setPositionAndUpdate(player.getBedLocation(id).posX, player.getBedLocation(id).posY,
+ player.getBedLocation(id).posZ);
else
- player.setPositionAndUpdate(
- player.worldObj.getSpawnPoint().posX,
- player.worldObj.getSpawnPoint().posY,
- player.worldObj.getSpawnPoint().posZ);
+ player.setPositionAndUpdate(player.worldObj.getSpawnPoint().posX,
+ player.worldObj.getSpawnPoint().posY, player.worldObj.getSpawnPoint().posZ);
}
}
@Override
- public void onEntityAttacked(ItemStack item, EntityPlayer player,
- Entity target, Item jewelry, float amount) {
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) {
if (jewelry instanceof ItemRing) {
// Negative ring
if (target instanceof EntityEnderman)
- player.addPotionEffect(new PotionEffect(
- Potion.weakness.id, 400, 2,
- true));
+ player.addPotionEffect(new PotionEffect(Potion.weakness.id, 400, 2, true));
// Positive ring
else
- target.setPosition(target.posX
- + rand.nextInt(16)
- - rand.nextInt(16),
- target.posY + rand.nextInt(
- 4),
- target.posZ + rand.nextInt(
- 16)
- - rand.nextInt(16));
+ target.setPosition(target.posX + rand.nextInt(16) - rand.nextInt(16), target.posY + rand.nextInt(4),
+ target.posZ + rand.nextInt(16) - rand.nextInt(16));
}
}
@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) {
return false;
}
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;
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java index 3b79390..95f52b5 100755 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java @@ -25,68 +25,39 @@ public class EffectObsidian extends ModifierEffects { }
@Override
- public void action(ItemStack item, EntityPlayer player,
- Item jewelry) {
- NBTTagCompound playerInfo = PlayerUtils
- .getModPlayerPersistTag(player,
- Variables.MODID);
+ 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));
+ 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;
+ 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);
+ 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));
+ 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));
+ 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 boolean onPlayerAttackedCancellable(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"))) {
+ public boolean onPlayerAttackedCancellable(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);
+ playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1);
} else {
playerInfo.setInteger("protected", 1);
}
@@ -94,16 +65,11 @@ public class EffectObsidian extends ModifierEffects { if (playerInfo.getInteger("protected") < 2000) {
return true;
}
- player.attackEntityFrom(DamageSourceList.weak,
- player.getHealth() * 3F);
+ player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F);
}
- if (jewelry instanceof ItemBracelet
- && source == DamageSource.fall) {
+ if (jewelry instanceof ItemBracelet && source == DamageSource.fall) {
if (playerInfo.hasKey("falls")) {
- playerInfo.setInteger("falls",
- playerInfo.getInteger(
- "falls")
- + 1);
+ playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1);
} else {
playerInfo.setInteger("falls", 1);
}
@@ -115,45 +81,28 @@ public class EffectObsidian extends ModifierEffects { }
@Override
- public void onPlayerDead(ItemStack item, EntityPlayer player,
- DamageSource source, Item jewelry) {
- NBTTagCompound playerInfo = PlayerUtils
- .getModPlayerPersistTag(player,
- Variables.MODID);
+ 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);
}
@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 playerInfo = PlayerUtils
- .getModPlayerPersistTag(player,
- Variables.MODID);
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
NBTTagCompound enemyData = target.getEntityData();
// Positive ring
- if (jewelry instanceof ItemRing
- && playerInfo.getInteger("strikes") < 2000
- && !player.worldObj.isRemote) {
+ if (jewelry instanceof ItemRing && playerInfo.getInteger("strikes") < 2000 && !player.worldObj.isRemote) {
if (enemyData.getInteger("reAttacked") == 0) {
if (playerInfo.hasKey("strikes"))
- playerInfo.setInteger("strikes",
- playerInfo.getInteger(
- "strikes")
- + 1);
+ playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1);
else
- playerInfo.setInteger("strikes",
- 1);
+ playerInfo.setInteger("strikes", 1);
// Negative ring
- enemyData.setInteger("reAttacked",
- enemyData.getInteger(
- "reAttacked")
- + 1);
- target.attackEntityFrom(DamageSource
- .causePlayerDamage(player),
- amount * 1.5F);
+ enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1);
+ target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 1.5F);
return true;
}
if (enemyData.getInteger("reAttacked") == 1)
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java b/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java index ee5f64c..06498f4 100755 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java @@ -4,8 +4,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import darkknight.jewelrycraft.api.ModifierEffects;
public class EffectsList {
- public static ModifierEffects blazePowder, enderEye, feather,
- enderPearl, obsidian;
+ public static ModifierEffects blazePowder, enderEye, feather, enderPearl, obsidian;
public static void postInit(FMLPostInitializationEvent e) {
blazePowder = new EffectBlazePowder();
|
