diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-06-05 01:53:14 +0100 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-06-05 01:53:14 +0100 |
| commit | a6a3bfa6f313adba5afe6eb4a0da049a8d641cfc (patch) | |
| tree | 56da97ba430232a7d0da51a3b8b9f444d96325c7 /src/main/java/darkknight/jewelrycraft/effects | |
| parent | 40487f07fa5ef31fde99713c0b842d34a0ba3622 (diff) | |
Stuff!
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects')
5 files changed, 456 insertions, 470 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java index 1ddc364..17db979 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java @@ -1,85 +1,82 @@ -package darkknight.jewelrycraft.effects; - -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import darkknight.jewelrycraft.api.ModifierEffects; -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 EffectBlazePowder extends ModifierEffects -{ - public EffectBlazePowder() - { - super(new ItemStack(Items.blaze_powder)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemNecklace && exists){ - // Positive for necklace - 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); - } - // Negative for bracelet - if (jewelry instanceof ItemBracelet && exists && 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); - if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D; - } - // Negative for earrings - if (jewelry instanceof ItemEarrings && exists){ - 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) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - // Balanced for ring - if (jewelry instanceof ItemRing && exists && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2); - return false; - } - - @Override - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - return false; - } - - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - {} - - 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 && rand.nextInt(4) == 0) if (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); - playerInfo.setBoolean("negateDamage", true); - } - // Positive for bracelet - if (jewelry instanceof ItemBracelet && exists) 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)) playerInfo.setBoolean("negateDamage", true); - } -} +package darkknight.jewelrycraft.effects;
+
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
+import darkknight.jewelrycraft.api.ModifierEffects;
+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 EffectBlazePowder extends ModifierEffects
+{
+ public EffectBlazePowder()
+ {
+ super(new ItemStack(Items.blaze_powder));
+ }
+
+ @Override
+ 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();
+ // Negative for necklace
+ 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;
+ 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;
+ }
+ // Negative for earrings
+ if (jewelry instanceof ItemEarrings){
+ 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)
+ {
+ // Balanced for ring
+ if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2);
+ return false;
+ }
+
+ @Override
+ public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ {
+ return false;
+ }
+
+ public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
+ {}
+
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0) if (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);
+ playerInfo.setBoolean("negateDamage", 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)) playerInfo.setBoolean("negateDamage", true);
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java index afaa376..4457961 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java @@ -1,90 +1,88 @@ -package darkknight.jewelrycraft.effects; - -import net.minecraft.block.BlockOre; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.GameSettings.Options; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -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.world.ChunkPosition; -import net.minecraft.world.biome.BiomeGenBase; -import cpw.mods.fml.relauncher.ReflectionHelper; -import darkknight.jewelrycraft.api.ModifierEffects; -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.Variables; - -public class EffectEnderEye extends ModifierEffects -{ - private boolean originalVD = false; - private float originalViewDistance; - - public EffectEnderEye() - { - super(new ItemStack(Items.ender_eye)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemEarrings && exists && !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 && exists && !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 && exists && !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 && exists && !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 && exists) Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, 2.2F - JewelryNBT.numberOfModifiers(item) * 0.1F); - // Positive ring - if (jewelry instanceof ItemRing && exists && 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) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - // Negative necklace - if (jewelry instanceof ItemNecklace && exists && !player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100 + JewelryNBT.numberOfModifiers(item)*30, 1)); - } -} +package darkknight.jewelrycraft.effects;
+
+import net.minecraft.block.BlockOre;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.settings.GameSettings.Options;
+import net.minecraft.entity.monster.EntityEnderman;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+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.world.ChunkPosition;
+import net.minecraft.world.biome.BiomeGenBase;
+import cpw.mods.fml.relauncher.ReflectionHelper;
+import darkknight.jewelrycraft.api.ModifierEffects;
+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.Variables;
+
+public class EffectEnderEye extends ModifierEffects
+{
+ private boolean originalVD = false;
+ private float originalViewDistance;
+
+ public EffectEnderEye()
+ {
+ super(new ItemStack(Items.ender_eye));
+ }
+
+ @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.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));
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java index 531a1c1..0ea08c7 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java @@ -1,95 +1,92 @@ -package darkknight.jewelrycraft.effects; - -import java.util.Iterator; -import java.util.List; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityTNTPrimed; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.Items; -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.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import darkknight.jewelrycraft.api.ModifierEffects; -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 EffectEnderPearl extends ModifierEffects -{ - public EffectEnderPearl() - { - super(new ItemStack(Items.ender_pearl)); - } - - @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 ItemEarrings && exists){ - 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 && exists) player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, -10, true)); - // Negative bracelet - if (jewelry instanceof ItemBracelet && exists && 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) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - // Positive Necklace - if (jewelry instanceof ItemNecklace && exists && source.getEntity() != null) source.getEntity().attackEntityFrom(source, amount); - // Positive bracelet - if (jewelry instanceof ItemBracelet && exists && !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) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - NBTTagCompound enemyData = target.getEntityData(); - if (jewelry instanceof ItemRing && exists){ - // 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; - } -} +package darkknight.jewelrycraft.effects;
+
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityTNTPrimed;
+import net.minecraft.entity.monster.EntityEnderman;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.projectile.EntityArrow;
+import net.minecraft.init.Items;
+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.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
+import darkknight.jewelrycraft.api.ModifierEffects;
+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 EffectEnderPearl extends ModifierEffects
+{
+ public EffectEnderPearl()
+ {
+ super(new ItemStack(Items.ender_pearl));
+ }
+
+ @Override
+ public void action(ItemStack item, EntityPlayer player, Item jewelry)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ 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)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ // 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)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ NBTTagCompound enemyData = target.getEntityData();
+ 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;
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java index aa427b1..d0a48d5 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java @@ -1,98 +1,95 @@ -package darkknight.jewelrycraft.effects; - -import java.util.Iterator; -import java.util.List; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.Items; -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.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -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.potions.PotionList; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class EffectFeather extends ModifierEffects -{ - public EffectFeather() - { - super(new ItemStack(Items.feather)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - // Positive earrings - if (jewelry instanceof ItemEarrings && exists){ - 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 && exists){ - // 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 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(); - if (jewelry instanceof ItemRing && exists){ - 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.1F)); - // 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)); - playerInfo.setBoolean("weakDamage", true); - } - if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); - } - } - - @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); - // Positive necklace - if (jewelry instanceof ItemNecklace && exists && 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"))); - playerInfo.setBoolean("negateDamage", true); - } - // Negative necklace - if (jewelry instanceof ItemNecklace && exists && (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 && exists && source.damageType.equals("arrow") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); - } -} +package darkknight.jewelrycraft.effects;
+
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.projectile.EntityArrow;
+import net.minecraft.init.Items;
+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.AxisAlignedBB;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+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.potions.PotionList;
+import darkknight.jewelrycraft.util.JewelryNBT;
+import darkknight.jewelrycraft.util.PlayerUtils;
+import darkknight.jewelrycraft.util.Variables;
+
+public class EffectFeather extends ModifierEffects
+{
+ public EffectFeather()
+ {
+ super(new ItemStack(Items.feather));
+ }
+
+ @Override
+ public void action(ItemStack item, EntityPlayer player, Item jewelry)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ // 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 void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ NBTTagCompound enemyData = target.getEntityData();
+ if (jewelry instanceof ItemRing){
+ 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.1F));
+ // 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));
+ playerInfo.setBoolean("weakDamage", true);
+ }
+ if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0);
+ }
+ }
+
+ @Override
+ public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount)
+ {
+ NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
+ // 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")));
+ playerInfo.setBoolean("negateDamage", 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") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F));
+ }
+}
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);
+ }
+ }
+}
|
