summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-04-12 16:29:24 +0300
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-04-12 16:29:24 +0300
commit4f29b0ed24e393be7074abd851e207aadab38196 (patch)
treebe8e5211a2956589c08b5e88b5e083e6aaeb96ce /src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
parent6312636fd9a4d0f56dc7c9ff474a99d879bcb4e9 (diff)
I rearranged files and added a few cool stuff.
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java')
-rw-r--r--src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
index eb7bef7..4c36593 100644
--- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
+++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java
@@ -27,6 +27,7 @@ public class EffectEnderEye extends ModifierEffects
{
private boolean originalVD = false;
private float originalViewDistance;
+
public EffectEnderEye()
{
super(new ItemStack(Items.ender_eye));
@@ -35,8 +36,8 @@ public class EffectEnderEye extends ModifierEffects
@Override
public void action(ItemStack item, EntityPlayer player, Item jewelry)
{
- int pos = JewelryNBT.doesModifierExist(item, modifier);
- if (jewelry instanceof ItemEarrings && pos != -1 && !player.worldObj.isRemote){
+ 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");
@@ -46,34 +47,41 @@ public class EffectEnderEye extends ModifierEffects
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));
+ // 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));
}
}
}
- if (jewelry instanceof ItemNecklace && pos != -1 && !player.worldObj.isRemote){
+ // 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);
- Minecraft.getMinecraft().thePlayer.motionZ += 0.01D * Math.signum((double)chunkposition.chunkPosZ - player.posZ);
+ 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);
}
}
- 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);
+ // 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 + "You sense some " + player.worldObj.getBlock(i, j, k).getLocalizedName() + " around you."));
+ 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)
{
- int pos = JewelryNBT.doesModifierExist(item, modifier);
- if (jewelry instanceof ItemNecklace && pos != -1 && !player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 1));
+ 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));
}
}