summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-03-23 14:25:27 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-03-23 14:25:27 +0000
commite86949a1ad3269ec66c9de65e2c92f5e66251411 (patch)
treeabe7a3b14d7a5f7bb27a916a991f8911de94c1d2 /java/darkknight/jewelrycraft/effects/EffectEnderEye.java
parent12cb40ba14e76b999a381b1f122bfce73223fd38 (diff)
More stuff. I don't even know by this point....
Diffstat (limited to 'java/darkknight/jewelrycraft/effects/EffectEnderEye.java')
-rw-r--r--java/darkknight/jewelrycraft/effects/EffectEnderEye.java76
1 files changed, 51 insertions, 25 deletions
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));
}
}