diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-03-23 14:25:27 +0000 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-03-23 14:25:27 +0000 |
| commit | e86949a1ad3269ec66c9de65e2c92f5e66251411 (patch) | |
| tree | abe7a3b14d7a5f7bb27a916a991f8911de94c1d2 /java/darkknight/jewelrycraft/effects | |
| parent | 12cb40ba14e76b999a381b1f122bfce73223fd38 (diff) | |
More stuff. I don't even know by this point....
Diffstat (limited to 'java/darkknight/jewelrycraft/effects')
4 files changed, 148 insertions, 91 deletions
diff --git a/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java index efec29b..949d0d8 100644 --- a/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java +++ b/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java @@ -6,6 +6,7 @@ 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.item.ItemBracelet; @@ -13,6 +14,7 @@ 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; public class EffectBlazePowder extends ModifierEffects { @@ -33,15 +35,19 @@ public class EffectBlazePowder extends ModifierEffects if (player.isInWater()) player.attackEntityFrom(DamageSource.drown, 1f); } //Negative for bracelet - if (jewelry instanceof ItemBracelet && pos != -1) if(player.isInWater()) player.fallDistance *= 0.8F; + if (jewelry instanceof ItemBracelet && pos != -1 && player.isInWater()){ + player.motionX *= 0.6D; + player.motionY *= 0.6D; + player.motionZ *= 0.6D; + player.motionY -= 0.02D; + if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D; + } //Negative for earrings if (jewelry instanceof ItemEarrings && pos != -1){ if (player.getAir() >= 300) player.setAir(player.getAir() / 2); - else player.setAir(player.getAir() - 1); - - } - + else player.setAir(player.getAir() - 1); + } } @Override @@ -56,31 +62,34 @@ public class EffectBlazePowder extends ModifierEffects @Override public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) { - int pos = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemEarrings && pos != -1 && player.worldObj.rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){ - //Positive for earrings - int stackSize = JewelryNBT.modifier(item).get(pos).stackSize; - player.heal((float)(0.05 * stackSize)); - return true; - } - //Positive for bracelet - if (jewelry instanceof ItemBracelet && pos != -1) 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; +// int pos = JewelryNBT.doesModifierExist(item, modifier); +// if (jewelry instanceof ItemEarrings && pos != -1 && rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){ +// //Positive for earrings +// int stackSize = JewelryNBT.modifier(item).get(pos).stackSize; +// player.heal((float)(0.05 * stackSize)); +// return true; +// } +// //Positive for bracelet +// if (jewelry instanceof ItemBracelet && pos != -1) 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; } - @Override public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) { + } - @Override public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) { - } - - @Override - public boolean onPlayerFall(ItemStack item, EntityPlayer player, Item jewelry) - { - return false; + int pos = JewelryNBT.doesModifierExist(item, modifier); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + if (jewelry instanceof ItemEarrings && pos != -1 && rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){ + //Positive for earrings + int stackSize = JewelryNBT.modifier(item).get(pos).stackSize; + player.heal((float)(0.05 * stackSize)); + playerInfo.setBoolean("negateDamage", true); + } + //Positive for bracelet + if (jewelry instanceof ItemBracelet && pos != -1) 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/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/java/darkknight/jewelrycraft/effects/EffectEnderEye.java index 886b18d..eb7bef7 100644 --- a/java/darkknight/jewelrycraft/effects/EffectEnderEye.java +++ b/java/darkknight/jewelrycraft/effects/EffectEnderEye.java @@ -1,16 +1,32 @@ package darkknight.jewelrycraft.effects; -import net.minecraft.entity.Entity; +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.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.biome.BiomeGenBase; +import cpw.mods.fml.relauncher.ReflectionHelper; +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; public class EffectEnderEye extends ModifierEffects { + private boolean originalVD = false; + private float originalViewDistance; public EffectEnderEye() { super(new ItemStack(Items.ender_eye)); @@ -20,34 +36,44 @@ public class EffectEnderEye extends ModifierEffects public void action(ItemStack item, EntityPlayer player, Item jewelry) { int pos = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemNecklace && pos != -1) ; - } - - @Override - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - return false; - } - - @Override - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - return false; - } - - @Override - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { + if (jewelry instanceof ItemEarrings && pos != -1 && !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)){ + enderman.setTarget(null); + if (!player.isPotionActive(Potion.confusion) || player.getActivePotionEffect(Potion.confusion).getDuration() <= 80) player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 2)); + } + } + } + if (jewelry instanceof ItemNecklace && pos != -1 && !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); + Minecraft.getMinecraft().thePlayer.motionZ += 0.01D * Math.signum((double)chunkposition.chunkPosZ - player.posZ); + } + } + if (jewelry instanceof ItemBracelet && pos != -1 && !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, 140, 1)); + if (jewelry instanceof ItemBracelet && pos != -1 && !player.worldObj.isRemote && rand.nextInt(500) == 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 ItemRing && pos != -1 && rand.nextInt(200) == 12){ + Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, 1.0F); + 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 + "You sense some " + player.worldObj.getBlock(i, j, k).getLocalizedName() + " around you.")); + } } @Override public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) { - } - - @Override - public boolean onPlayerFall(ItemStack item, EntityPlayer player, Item jewelry) - { - return false; + int pos = JewelryNBT.doesModifierExist(item, modifier); + if (jewelry instanceof ItemNecklace && pos != -1 && !player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1)); } } diff --git a/java/darkknight/jewelrycraft/effects/EffectFeather.java b/java/darkknight/jewelrycraft/effects/EffectFeather.java index b331044..2acaf76 100644 --- a/java/darkknight/jewelrycraft/effects/EffectFeather.java +++ b/java/darkknight/jewelrycraft/effects/EffectFeather.java @@ -1,16 +1,25 @@ package darkknight.jewelrycraft.effects; +import java.util.Iterator; +import java.util.List; import net.minecraft.entity.Entity; 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.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; 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; public class EffectFeather extends ModifierEffects { @@ -23,47 +32,57 @@ public class EffectFeather extends ModifierEffects public void action(ItemStack item, EntityPlayer player, Item jewelry) { int pos = JewelryNBT.doesModifierExist(item, modifier); - // Positive necklace - if (jewelry instanceof ItemNecklace && pos != -1 && !player.onGround){ - player.motionY = -10D; - System.out.println(player.motionY); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + // Positive earrings + if (jewelry instanceof ItemEarrings && pos != -1){ + 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 (rand.nextInt(3) == 0 && (arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player)) || arrow.canBePickedUp == 0)) arrow.setDead(); + } + } } - } - - @Override - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - int pos = JewelryNBT.doesModifierExist(item, modifier); - // if (jewelry instanceof ItemNecklace && pos != -1) player.fallDistance *= 0.5F; - if (jewelry instanceof ItemBracelet && pos != -1) return true; - return false; - } - - @Override - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - int pos = JewelryNBT.doesModifierExist(item, modifier); // Positive bracelet - if (jewelry instanceof ItemBracelet && pos != -1) return true; - return true; + if (jewelry instanceof ItemBracelet && pos != -1){ + if (player.motionY < 0) player.motionY *= 0.6D; + player.setAIMoveSpeed(player.getAIMoveSpeed() / 2); + player.fallDistance = 0F; + } } @Override public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - {} - - @Override - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) { int pos = JewelryNBT.doesModifierExist(item, modifier); - // Negative necklace - if (jewelry instanceof ItemNecklace && pos != -1 && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * 2F); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + NBTTagCompound enemyData = target.getEntityData(); + if (jewelry instanceof ItemRing && pos != -1 && enemyData.getInteger("reAttacked") == 0){ + enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1); + target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount / 2F); + if (rand.nextInt(2) == 0){ + enemyData.setInteger("stunTime", 50); + enemyData.setBoolean("stunned", true); + } + playerInfo.setBoolean("weakDamage", true); + } + if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); } @Override - public boolean onPlayerFall(ItemStack item, EntityPlayer player, Item jewelry) + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) { int pos = JewelryNBT.doesModifierExist(item, modifier); - return false; + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + if (jewelry instanceof ItemNecklace && pos != -1 && rand.nextInt(4) == 0 && source != DamageSourceList.weak && source != DamageSource.inFire && source != DamageSource.onFire && source != DamageSource.lava){ + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The necklace protected you from taking damage!")); + playerInfo.setBoolean("negateDamage", true); + } + // Negative necklace + if (jewelry instanceof ItemNecklace && pos != -1 && (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava) && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * 3F); + // Negative earrings + if (jewelry instanceof ItemEarrings && pos != -1 && source.damageType.equals("arrow") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * 2F); } } diff --git a/java/darkknight/jewelrycraft/effects/ModifierEffects.java b/java/darkknight/jewelrycraft/effects/ModifierEffects.java index 2d62639..d3c8e38 100644 --- a/java/darkknight/jewelrycraft/effects/ModifierEffects.java +++ b/java/darkknight/jewelrycraft/effects/ModifierEffects.java @@ -1,15 +1,17 @@ package darkknight.jewelrycraft.effects; import java.util.ArrayList; +import java.util.Random; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; -public abstract class ModifierEffects +public class ModifierEffects { protected ItemStack modifier; + protected Random rand = new Random(); protected static ArrayList<ModifierEffects> effects = new ArrayList<ModifierEffects>(); /** @@ -34,7 +36,8 @@ public abstract class ModifierEffects * @param player * @param jewelry */ - public abstract void action(ItemStack item, EntityPlayer player, Item jewelry); + public void action(ItemStack item, EntityPlayer player, Item jewelry) + {}; /** * @param item @@ -43,7 +46,10 @@ public abstract class ModifierEffects * @param jewelry * @return */ - public abstract boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount); + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + return false; + } /** * @param item @@ -52,24 +58,20 @@ public abstract class ModifierEffects * @param jewelry * @return */ - public abstract boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount); - /** - * @param item - * @param player - * @param target - * @param jewelry - * @return - */ - public abstract void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount); + public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + return false; + } /** * @param item * @param player - * @param source + * @param target * @param jewelry * @return */ - public abstract void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount); + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + {} /** * @param item @@ -78,5 +80,6 @@ public abstract class ModifierEffects * @param jewelry * @return */ - public abstract boolean onPlayerFall(ItemStack item, EntityPlayer player, Item jewelry); + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + {} } |
