forked from TAIGA/TAIGA
test of new AITask
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package com.sosnitzka.ztic_addon.traits;
|
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.EntityCreature;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
@@ -9,9 +9,6 @@ import net.minecraft.util.text.TextFormatting;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Robert on 03.06.2016.
|
|
||||||
*/
|
|
||||||
public class TraitHaunted extends AbstractTrait {
|
public class TraitHaunted extends AbstractTrait {
|
||||||
|
|
||||||
public TraitHaunted() {
|
public TraitHaunted() {
|
||||||
@@ -23,16 +20,7 @@ public class TraitHaunted extends AbstractTrait {
|
|||||||
public void onHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean isCritical) {
|
public void onHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean isCritical) {
|
||||||
if (target instanceof EntityLiving) {
|
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 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());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,14 +11,14 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class EntityPanic extends EntityAIBase {
|
public class EntityAIPermanentPanic extends EntityAIBase {
|
||||||
private EntityCreature theEntityCreature;
|
private EntityCreature theEntityCreature;
|
||||||
protected double speed;
|
private double speed;
|
||||||
private double randPosX;
|
private double randPosX;
|
||||||
private double randPosY;
|
private double randPosY;
|
||||||
private double randPosZ;
|
private double randPosZ;
|
||||||
|
|
||||||
public EntityPanic(EntityCreature creature, double speedIn) {
|
public EntityAIPermanentPanic(EntityCreature creature, double speedIn) {
|
||||||
this.theEntityCreature = creature;
|
this.theEntityCreature = creature;
|
||||||
this.speed = speedIn;
|
this.speed = speedIn;
|
||||||
this.setMutexBits(1);
|
this.setMutexBits(1);
|
||||||
@@ -28,30 +28,26 @@ public class EntityPanic extends EntityAIBase {
|
|||||||
* Returns whether the EntityAIBase should begin execution.
|
* Returns whether the EntityAIBase should begin execution.
|
||||||
*/
|
*/
|
||||||
public boolean shouldExecute() {
|
public boolean shouldExecute() {
|
||||||
if (this.theEntityCreature.getAITarget() == null && !this.theEntityCreature.isBurning()) {
|
Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
|
||||||
|
|
||||||
|
if (vec3d == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 15, 4);
|
this.randPosX = vec3d.xCoord;
|
||||||
|
this.randPosY = vec3d.yCoord;
|
||||||
|
this.randPosZ = vec3d.zCoord;
|
||||||
|
|
||||||
if (vec3d == null) {
|
if (this.theEntityCreature.isBurning()) {
|
||||||
return false;
|
BlockPos blockpos = this.getRandPos(this.theEntityCreature.worldObj, this.theEntityCreature, 5, 4);
|
||||||
} else {
|
|
||||||
this.randPosX = vec3d.xCoord;
|
|
||||||
this.randPosY = vec3d.yCoord;
|
|
||||||
this.randPosZ = vec3d.zCoord;
|
|
||||||
|
|
||||||
if (this.theEntityCreature.isBurning()) {
|
if (blockpos != null) {
|
||||||
BlockPos blockpos = this.getRandPos(this.theEntityCreature.worldObj, this.theEntityCreature, 15, 4);
|
this.randPosX = (double) blockpos.getX();
|
||||||
|
this.randPosY = (double) blockpos.getY();
|
||||||
if (blockpos != null) {
|
this.randPosZ = (double) blockpos.getZ();
|
||||||
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) {
|
private BlockPos getRandPos(World worldIn, Entity entityIn, int horizontalRange, int verticalRange) {
|
||||||
BlockPos blockpos = new BlockPos(entityIn);
|
BlockPos blockpos = new BlockPos(entityIn);
|
||||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||||
int i = blockpos.getX();
|
int i = blockpos.getX();
|
||||||
int j = blockpos.getY();
|
int j = blockpos.getY();
|
||||||
int k = blockpos.getZ();
|
int k = blockpos.getZ();
|
||||||
@@ -81,8 +77,8 @@ public class EntityPanic extends EntityAIBase {
|
|||||||
for (int l = i - horizontalRange; l <= i + horizontalRange; ++l) {
|
for (int l = i - horizontalRange; l <= i + horizontalRange; ++l) {
|
||||||
for (int i1 = j - verticalRange; i1 <= j + verticalRange; ++i1) {
|
for (int i1 = j - verticalRange; i1 <= j + verticalRange; ++i1) {
|
||||||
for (int j1 = k - horizontalRange; j1 <= k + horizontalRange; ++j1) {
|
for (int j1 = k - horizontalRange; j1 <= k + horizontalRange; ++j1) {
|
||||||
blockpos$mutableblockpos.setPos(l, i1, j1);
|
mutableBlockPos.setPos(l, i1, j1);
|
||||||
IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
|
IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos);
|
||||||
Block block = iblockstate.getBlock();
|
Block block = iblockstate.getBlock();
|
||||||
|
|
||||||
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
|
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
|
||||||
@@ -90,7 +86,7 @@ public class EntityPanic extends EntityAIBase {
|
|||||||
|
|
||||||
if (f1 < f) {
|
if (f1 < f) {
|
||||||
f = f1;
|
f = f1;
|
||||||
blockpos1 = new BlockPos(blockpos$mutableblockpos);
|
blockpos1 = new BlockPos(mutableBlockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user