summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects')
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java73
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java280
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java150
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java174
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java197
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/effects/EffectsList.java23
6 files changed, 569 insertions, 328 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
index 678aa51..c735b2c 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java
@@ -24,42 +24,89 @@ public class EffectBlazePowder extends ModifierEffects {
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) player.extinguish();
+ 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);
+ if (player.isInWater())
+ 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;
+ 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);
- if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D;
+ player.motionY -= (0.02D
+ + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D);
+ if (player.isCollidedHorizontally)
+ player.motionY = 0.30000001192092896D;
}
// Negative for earrings
if (jewelry instanceof ItemEarrings) {
- if (player.getAir() >= 300) player.setAir(player.getAir() / 2);
- else player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item));
+ if (player.getAir() >= 300)
+ player.setAir(player.getAir() / 2);
+ else
+ player.setAir(player.getAir()
+ - JewelryNBT.numberOfModifiers(item));
}
}
@Override
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) {
+ 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) target.setFire(2);
+ if (jewelry instanceof ItemRing && !player.isInWater()
+ && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
+ target.setFire(2);
return false;
}
- public boolean onPlayerAttackedCacellable(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) {
+ @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) {
// Positive for earrings
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 || 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)) return true;
+ if (jewelry instanceof ItemBracelet)
+ 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)) {
+ return true;
+ }
+
return false;
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
index 4ae0951..6fcfac6 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
@@ -27,104 +27,184 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.biome.BiomeGenBase;
-public class EffectEnderEye extends ModifierEffects
-{
- public EffectEnderEye()
- {
- super(new ItemStack(Items.ender_eye));
- }
-
- public void onJewelryEquipped(ItemStack item, Item jewelry)
- {
- if (jewelry instanceof ItemRing)
- setViewDistance(item, Minecraft.getMinecraft().gameSettings.renderDistanceChunks <= 2 ? 10 : Minecraft.getMinecraft().gameSettings.renderDistanceChunks);
- }
-
- public void onJewelryUnequipped(ItemStack item, Item jewelry)
- {
- if (jewelry instanceof ItemRing)
- Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, getViewDistance(item));
- }
-
- @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))){
- EntityEnderman enderman = (EntityEnderman)e;
- 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()), 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)) {
- // Positive earrings
- if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0)
- enderman.setTarget(null);
- // Negative earrings
- if (!player.isPotionActive(Potion.confusion) || player.getActivePotionEffect(Potion.confusion).getDuration() <= 80)
- player.addPotionEffect(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 (chunkposition != null) {
- Minecraft.getMinecraft().thePlayer.motionX += 0.01D * 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);
- }
- }
- // 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));
- // 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));
- // 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);
- // 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")));
- }
- }
-
- @Override
- 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));
- }
-
- public static void setViewDistance(ItemStack item, int viewDistance)
- {
- NBTTagCompound itemStackData;
- if (item.hasTagCompound())
- itemStackData = item.getTagCompound();
- else{
- itemStackData = new NBTTagCompound();
- item.setTagCompound(itemStackData);
- }
- itemStackData.setInteger("viewDistance", viewDistance);
- }
-
- public static int getViewDistance(ItemStack item)
- {
- NBTTagCompound itemStackData;
- if (item.hasTagCompound())
- itemStackData = item.getTagCompound();
- else{
- itemStackData = new NBTTagCompound();
- item.setTagCompound(itemStackData);
- }
- int i = itemStackData.getInteger("viewDistance");
- return i;
- }
+public class EffectEnderEye extends ModifierEffects {
+ public EffectEnderEye() {
+ super(new ItemStack(Items.ender_eye));
+ }
+
+ @Override
+ public void onJewelryEquipped(ItemStack item, Item jewelry) {
+ if (jewelry instanceof ItemRing) {
+ int viewDistance;
+
+ if (Minecraft
+ .getMinecraft().gameSettings.renderDistanceChunks <= 2) {
+ viewDistance = 10;
+ } else {
+ viewDistance = Minecraft
+ .getMinecraft().gameSettings.renderDistanceChunks;
+ }
+
+ setViewDistance(item, viewDistance);
+ }
+ }
+
+ @Override
+ public void onJewelryUnequipped(ItemStack item, Item jewelry) {
+ if (jewelry instanceof ItemRing)
+ 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))) {
+ EntityEnderman enderman = (EntityEnderman) e;
+
+ 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()),
+ 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)) {
+ // Positive earrings
+ if (rand.nextInt(
+ JewelryNBT.numberOfModifiers(item)) == 0)
+ enderman.setTarget(null);
+ // Negative earrings
+ if (!player.isPotionActive(Potion.confusion) || player
+ .getActivePotionEffect(Potion.confusion)
+ .getDuration() <= 80)
+ player.addPotionEffect(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 (chunkposition != null) {
+ Minecraft.getMinecraft().thePlayer.motionX += 0.01D
+ * 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);
+ }
+ }
+ // 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));
+ // 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));
+ // 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);
+ // 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")));
+ }
+ }
+
+ @Override
+ 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));
+ }
+
+ public static void setViewDistance(ItemStack item, int viewDistance) {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ itemStackData.setInteger("viewDistance", viewDistance);
+ }
+
+ public static int getViewDistance(ItemStack item) {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ int i = itemStackData.getInteger("viewDistance");
+ return i;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
index 33a765b..0b48ba2 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java
@@ -2,6 +2,7 @@ package darkknight.jewelrycraft.effects;
import java.util.Iterator;
import java.util.List;
+
import darkknight.jewelrycraft.api.ModifierEffects;
import darkknight.jewelrycraft.item.ItemBracelet;
import darkknight.jewelrycraft.item.ItemEarrings;
@@ -20,65 +21,92 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
-public class EffectEnderPearl extends ModifierEffects
-{
- public EffectEnderPearl()
- {
- super(new ItemStack(Items.ender_pearl));
- }
-
- @Override
- 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()){
- Iterator iterator = list.iterator();
- while (iterator.hasNext()){
- 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);
- 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));
- }
- }
- }
- // Negative Necklace
- if (jewelry instanceof ItemNecklace) 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));
- }
-
- @Override
- 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);
- // Positive bracelet
- 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);
- else player.setPositionAndUpdate(player.worldObj.getSpawnPoint().posX, player.worldObj.getSpawnPoint().posY, player.worldObj.getSpawnPoint().posZ);
- }
- }
-
- 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));
- // 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));
- }
- }
-
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
- {
- return false;
- }
+public class EffectEnderPearl extends ModifierEffects {
+ public EffectEnderPearl() {
+ super(new ItemStack(Items.ender_pearl));
+ }
+
+ @Override
+ 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()) {
+ Iterator<?> iterator = list.iterator();
+ while (iterator.hasNext()) {
+ 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);
+ 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));
+ }
+ }
+ }
+ // Negative Necklace
+ if (jewelry instanceof ItemNecklace)
+ 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));
+ }
+
+ @Override
+ 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);
+ // Positive bracelet
+ 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);
+ else
+ 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) {
+ if (jewelry instanceof ItemRing) {
+ // Negative ring
+ if (target instanceof EntityEnderman)
+ 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));
+ }
+ }
+
+ @Override
+ 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 2ffaa11..a7f2c8e 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java
@@ -2,6 +2,7 @@ package darkknight.jewelrycraft.effects;
import java.util.Iterator;
import java.util.List;
+
import darkknight.jewelrycraft.api.ModifierEffects;
import darkknight.jewelrycraft.damage.DamageSourceList;
import darkknight.jewelrycraft.item.ItemBracelet;
@@ -27,67 +28,114 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
-public class EffectFeather extends ModifierEffects
-{
- public EffectFeather()
- {
- super(new ItemStack(Items.feather));
- }
-
- @Override
- 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()){
- 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) arrow.setDead();
- }
- }
- }
- 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.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));
- }
- }
-
- @Override
- public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
- {
- NBTTagCompound enemyData = target.getEntityData();
- 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));
- // 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));
- return true;
- }
- else enemyData.setInteger("reAttacked", 0);
- }
- return false;
- }
-
- @Override
- public boolean onPlayerAttackedCacellable(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 && source != DamageSource.lava){
- 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 != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (3F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
- // Negative earrings
- if (jewelry instanceof ItemEarrings && source.damageType.equals("arrow")) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
- return false;
- }
+public class EffectFeather extends ModifierEffects {
+ public EffectFeather() {
+ super(new ItemStack(Items.feather));
+ }
+
+ @Override
+ 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()) {
+ 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)
+ arrow.setDead();
+ }
+ }
+ }
+ 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.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));
+ }
+ }
+
+ @Override
+ 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 (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));
+ // 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));
+ return true;
+ }
+ enemyData.setInteger("reAttacked", 0);
+ }
+ return false;
+ }
+
+ @Override
+ 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
+ && source != DamageSource.lava) {
+ 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 != DamageSourceList.weak)
+ player.attackEntityFrom(DamageSourceList.weak, amount * (3F
+ + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
+ // Negative earrings
+ if (jewelry instanceof ItemEarrings
+ && source.damageType.equals("arrow"))
+ player.attackEntityFrom(DamageSourceList.weak, 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 f13b272..be1d233 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java
@@ -19,83 +19,122 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
-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 boolean onPlayerAttackedCacellable(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") < 2000) return 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") < 3000) return true;
- }
- return false;
- }
-
- 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 boolean onEntityAttackedCacellable(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") < 2000 && !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 * 1.5F);
- return true;
- }
- if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
- }
- return false;
- }
+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 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);
+ } else {
+ playerInfo.setInteger("protected", 1);
+ }
+ // Positive && Negative earrings
+ if (playerInfo.getInteger("protected") < 2000) {
+ return true;
+ }
+ 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") < 3000)
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ 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,
+ float amount) {
+ 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 (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 * 1.5F);
+ return true;
+ }
+ if (enemyData.getInteger("reAttacked") == 1)
+ enemyData.setInteger("reAttacked", 0);
+ }
+ return false;
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java b/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java
index 3df8169..ee5f64c 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectsList.java
@@ -3,16 +3,15 @@ package darkknight.jewelrycraft.effects;
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 void postInit(FMLPostInitializationEvent e)
- {
- blazePowder = new EffectBlazePowder();
- enderEye = new EffectEnderEye();
- feather = new EffectFeather();
- enderPearl = new EffectEnderPearl();
- obsidian = new EffectObsidian();
- }
+public class EffectsList {
+ public static ModifierEffects blazePowder, enderEye, feather,
+ enderPearl, obsidian;
+
+ public static void postInit(FMLPostInitializationEvent e) {
+ blazePowder = new EffectBlazePowder();
+ enderEye = new EffectEnderEye();
+ feather = new EffectFeather();
+ enderPearl = new EffectEnderPearl();
+ obsidian = new EffectObsidian();
+ }
}