summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Sosnitzka <robert.sosnitzka@gmail.com>2016-06-28 21:40:12 +0200
committerRobert Sosnitzka <robert.sosnitzka@gmail.com>2016-06-28 21:40:12 +0200
commit79445303759e0130fb2a2de7805ccff4fd6c957a (patch)
tree0634a737ffc012bcce22720407d830339d31aa2f /src
parentdf951e0abd900dee170ea6dd9b19edb3235b2a2c (diff)
Fixed trait 'haunted' to be more fun and useful!
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java15
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java17
2 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java b/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java
index 5f931e1..fb2ea4f 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java
@@ -4,6 +4,8 @@ import com.sosnitzka.ztic_addon.util.EntityAIPermanentPanic;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.monster.*;
+import net.minecraft.entity.passive.*;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
@@ -18,9 +20,16 @@ public class TraitHaunted extends AbstractTrait {
@Override
public void onHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean isCritical) {
- if (target instanceof EntityLiving) {
- //((EntityLiving) target).tasks.addTask(0, new EntityAIAvoidEntity((EntityCreature) target, EntityPlayer.class,16f, 2.0d, 2.4D));
- ((EntityLiving) target).tasks.addTask(0, new EntityAIPermanentPanic((EntityCreature) target, 2.0D));
+ if (random.nextFloat() < 0.1)
+ if (target instanceof EntityCow || target instanceof EntityZombie || target instanceof EntityWolf || target instanceof EntityPig || target instanceof EntitySpider ||
+ target instanceof EntityVillager || target instanceof EntitySheep || target instanceof EntityEnderman || target instanceof EntityEndermite ||
+ target instanceof EntityBlaze || target instanceof EntitySkeleton || target instanceof EntityWitch || target instanceof EntityHorse) {
+ ((EntityLiving) target).tasks.taskEntries.clear();
+ ((EntityLiving) target).tasks.taskEntries.clear();
+ ((EntityLiving) target).targetTasks.taskEntries.clear();
+ ((EntityLiving) target).targetTasks.taskEntries.clear();
+ ((EntityLiving) target).tasks.addTask(0, new EntityAIPermanentPanic((EntityCreature) target, target.getAIMoveSpeed() + 2.0D));
+
}
}
}
diff --git a/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java b/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java
index a5d95f5..86c04b9 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java
@@ -13,7 +13,7 @@ import net.minecraft.world.World;
public class EntityAIPermanentPanic extends EntityAIBase {
private EntityCreature theEntityCreature;
- private double speed;
+ protected double speed;
private double randPosX;
private double randPosY;
private double randPosZ;
@@ -21,13 +21,13 @@ public class EntityAIPermanentPanic extends EntityAIBase {
public EntityAIPermanentPanic(EntityCreature creature, double speedIn) {
this.theEntityCreature = creature;
this.speed = speedIn;
- this.setMutexBits(1);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute() {
+
Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
if (vec3d == null) {
@@ -45,10 +45,11 @@ public class EntityAIPermanentPanic extends EntityAIBase {
this.randPosY = (double) blockpos.getY();
this.randPosZ = (double) blockpos.getZ();
}
- }
+ }
return true;
- }
+ }
+
}
/**
@@ -67,7 +68,7 @@ public class EntityAIPermanentPanic extends EntityAIBase {
private BlockPos getRandPos(World worldIn, Entity entityIn, int horizontalRange, int verticalRange) {
BlockPos blockpos = new BlockPos(entityIn);
- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
+ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
int i = blockpos.getX();
int j = blockpos.getY();
int k = blockpos.getZ();
@@ -77,8 +78,8 @@ public class EntityAIPermanentPanic extends EntityAIBase {
for (int l = i - horizontalRange; l <= i + horizontalRange; ++l) {
for (int i1 = j - verticalRange; i1 <= j + verticalRange; ++i1) {
for (int j1 = k - horizontalRange; j1 <= k + horizontalRange; ++j1) {
- mutableBlockPos.setPos(l, i1, j1);
- IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos);
+ blockpos$mutableblockpos.setPos(l, i1, j1);
+ IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
Block block = iblockstate.getBlock();
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
@@ -86,7 +87,7 @@ public class EntityAIPermanentPanic extends EntityAIBase {
if (f1 < f) {
f = f1;
- blockpos1 = new BlockPos(mutableBlockPos);
+ blockpos1 = new BlockPos(blockpos$mutableblockpos);
}
}
}