summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiovanni Harting <539@idlegandalf.com>2016-06-28 14:39:54 +0200
committerGiovanni Harting <539@idlegandalf.com>2016-06-28 14:39:54 +0200
commitdf951e0abd900dee170ea6dd9b19edb3235b2a2c (patch)
tree074d244c4c7eb75b8192ce44f2dcff8e53b079ce /src
parenteecd0af847ac4a524d66b193c03c4791935ef7ba (diff)
test of new AITask
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java16
-rw-r--r--src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java (renamed from src/main/java/com/sosnitzka/ztic_addon/util/EntityPanic.java)46
2 files changed, 23 insertions, 39 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 3f33c90..5f931e1 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/traits/TraitHaunted.java
@@ -1,6 +1,6 @@
package com.sosnitzka.ztic_addon.traits;
-import com.sosnitzka.ztic_addon.util.EntityPanic;
+import com.sosnitzka.ztic_addon.util.EntityAIPermanentPanic;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@@ -9,9 +9,6 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import slimeknights.tconstruct.library.traits.AbstractTrait;
-/**
- * Created by Robert on 03.06.2016.
- */
public class TraitHaunted extends AbstractTrait {
public TraitHaunted() {
@@ -23,16 +20,7 @@ public class TraitHaunted extends AbstractTrait {
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 EntityPanic((EntityCreature) target, 2.0D));
+ ((EntityLiving) target).tasks.addTask(0, new EntityAIPermanentPanic((EntityCreature) target, 2.0D));
}
}
-
-
-
-
- /*@SubscribeEvent
- public void onDamage(LivingAttackEvent e){
- System.out.println(e.getEntity() + " " + e.getSource());
- }*/
-
}
diff --git a/src/main/java/com/sosnitzka/ztic_addon/util/EntityPanic.java b/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java
index 8820070..a5d95f5 100644
--- a/src/main/java/com/sosnitzka/ztic_addon/util/EntityPanic.java
+++ b/src/main/java/com/sosnitzka/ztic_addon/util/EntityAIPermanentPanic.java
@@ -11,14 +11,14 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
-public class EntityPanic extends EntityAIBase {
+public class EntityAIPermanentPanic extends EntityAIBase {
private EntityCreature theEntityCreature;
- protected double speed;
+ private double speed;
private double randPosX;
private double randPosY;
private double randPosZ;
- public EntityPanic(EntityCreature creature, double speedIn) {
+ public EntityAIPermanentPanic(EntityCreature creature, double speedIn) {
this.theEntityCreature = creature;
this.speed = speedIn;
this.setMutexBits(1);
@@ -28,30 +28,26 @@ public class EntityPanic extends EntityAIBase {
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute() {
- if (this.theEntityCreature.getAITarget() == null && !this.theEntityCreature.isBurning()) {
+ Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
+
+ if (vec3d == null) {
return false;
} else {
- Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 15, 4);
-
- if (vec3d == null) {
- return false;
- } else {
- this.randPosX = vec3d.xCoord;
- this.randPosY = vec3d.yCoord;
- this.randPosZ = vec3d.zCoord;
+ this.randPosX = vec3d.xCoord;
+ this.randPosY = vec3d.yCoord;
+ this.randPosZ = vec3d.zCoord;
- if (this.theEntityCreature.isBurning()) {
- BlockPos blockpos = this.getRandPos(this.theEntityCreature.worldObj, this.theEntityCreature, 15, 4);
+ if (this.theEntityCreature.isBurning()) {
+ BlockPos blockpos = this.getRandPos(this.theEntityCreature.worldObj, this.theEntityCreature, 5, 4);
- if (blockpos != null) {
- this.randPosX = (double) blockpos.getX();
- this.randPosY = (double) blockpos.getY();
- this.randPosZ = (double) blockpos.getZ();
- }
+ if (blockpos != null) {
+ this.randPosX = (double) blockpos.getX();
+ this.randPosY = (double) blockpos.getY();
+ this.randPosZ = (double) blockpos.getZ();
}
-
- return true;
}
+
+ return true;
}
}
@@ -71,7 +67,7 @@ public class EntityPanic extends EntityAIBase {
private BlockPos getRandPos(World worldIn, Entity entityIn, int horizontalRange, int verticalRange) {
BlockPos blockpos = new BlockPos(entityIn);
- BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
int i = blockpos.getX();
int j = blockpos.getY();
int k = blockpos.getZ();
@@ -81,8 +77,8 @@ public class EntityPanic 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) {
- blockpos$mutableblockpos.setPos(l, i1, j1);
- IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
+ mutableBlockPos.setPos(l, i1, j1);
+ IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos);
Block block = iblockstate.getBlock();
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
@@ -90,7 +86,7 @@ public class EntityPanic extends EntityAIBase {
if (f1 < f) {
f = f1;
- blockpos1 = new BlockPos(blockpos$mutableblockpos);
+ blockpos1 = new BlockPos(mutableBlockPos);
}
}
}