mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 01:44:27 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -24,28 +24,44 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
|
||||
private EntityNPCInterface theEntity;
|
||||
private World worldObj;
|
||||
/** The PathEntity being followed. */
|
||||
/**
|
||||
* The PathEntity being followed.
|
||||
*/
|
||||
protected NPCPath currentPath;
|
||||
private double speed;
|
||||
/** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */
|
||||
/**
|
||||
* The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space
|
||||
*/
|
||||
private IAttributeInstance pathSearchRange;
|
||||
protected float maxDistanceToWaypoint = 0.5F;
|
||||
private boolean noSunPathfind;
|
||||
/** Time, in number of ticks, following the current path */
|
||||
/**
|
||||
* Time, in number of ticks, following the current path
|
||||
*/
|
||||
private int totalTicks;
|
||||
/** The time when the last position check was done (to detect successful movement) */
|
||||
/**
|
||||
* The time when the last position check was done (to detect successful movement)
|
||||
*/
|
||||
private int ticksAtLastPos;
|
||||
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
|
||||
/**
|
||||
* Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck')
|
||||
*/
|
||||
private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||
private Vec3 timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||
private long timeoutTimer;
|
||||
private long lastTimeoutCheck;
|
||||
private double timeoutLimit;
|
||||
/** Specifically, if a wooden door block is even considered to be passable by the pathfinder */
|
||||
/**
|
||||
* Specifically, if a wooden door block is even considered to be passable by the pathfinder
|
||||
*/
|
||||
private boolean canPassOpenWoodenDoors = true;
|
||||
/** If door blocks are considered passable even when closed */
|
||||
/**
|
||||
* If door blocks are considered passable even when closed
|
||||
*/
|
||||
private boolean canPassClosedWoodenDoors;
|
||||
/** If water blocks are avoided (at least by the pathfinder) */
|
||||
/**
|
||||
* If water blocks are avoided (at least by the pathfinder)
|
||||
*/
|
||||
private boolean avoidsWater;
|
||||
/**
|
||||
* If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
|
||||
@@ -61,139 +77,112 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
|
||||
public PathNavigateFlying(EntityLiving entityIN, World worldIn) {
|
||||
super(entityIN, worldIn);
|
||||
this.theEntity = (EntityNPCInterface)entityIN;
|
||||
this.theEntity = (EntityNPCInterface) entityIN;
|
||||
this.worldObj = worldIn;
|
||||
this.pathSearchRange = entityIN.getEntityAttribute(SharedMonsterAttributes.followRange);
|
||||
}
|
||||
|
||||
public void updatePath()
|
||||
{
|
||||
if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L)
|
||||
{
|
||||
if (this.targetPos != null)
|
||||
{
|
||||
public void updatePath() {
|
||||
if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L) {
|
||||
if (this.targetPos != null) {
|
||||
this.currentPath = null;
|
||||
this.currentPath = this.getPathToXYZ(this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ());
|
||||
this.lastTimeUpdated = this.worldObj.getTotalWorldTime();
|
||||
this.tryUpdatePath = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.tryUpdatePath = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAvoidsWater(boolean p_75491_1_)
|
||||
{
|
||||
public void setAvoidsWater(boolean p_75491_1_) {
|
||||
this.avoidsWater = p_75491_1_;
|
||||
}
|
||||
|
||||
public boolean getAvoidsWater()
|
||||
{
|
||||
public boolean getAvoidsWater() {
|
||||
return this.avoidsWater;
|
||||
}
|
||||
|
||||
public void setBreakDoors(boolean p_75498_1_)
|
||||
{
|
||||
public void setBreakDoors(boolean p_75498_1_) {
|
||||
this.canPassClosedWoodenDoors = p_75498_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the entity can enter open doors
|
||||
*/
|
||||
public void setEnterDoors(boolean p_75490_1_)
|
||||
{
|
||||
public void setEnterDoors(boolean p_75490_1_) {
|
||||
this.canPassOpenWoodenDoors = p_75490_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the entity can break doors, false otherwise
|
||||
*/
|
||||
public boolean getCanBreakDoors()
|
||||
{
|
||||
public boolean getCanBreakDoors() {
|
||||
return this.canPassClosedWoodenDoors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the path should avoid sunlight
|
||||
*/
|
||||
public void setAvoidSun(boolean p_75504_1_)
|
||||
{
|
||||
public void setAvoidSun(boolean p_75504_1_) {
|
||||
this.noSunPathfind = p_75504_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speed
|
||||
*/
|
||||
public void setSpeed(double p_75489_1_)
|
||||
{
|
||||
public void setSpeed(double p_75489_1_) {
|
||||
this.speed = p_75489_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the entity can swim
|
||||
*/
|
||||
public void setCanSwim(boolean p_75495_1_)
|
||||
{
|
||||
public void setCanSwim(boolean p_75495_1_) {
|
||||
this.canSwim = p_75495_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum distance that the path finding will search in.
|
||||
*/
|
||||
public float getPathSearchRange()
|
||||
{
|
||||
return (float)this.pathSearchRange.getAttributeValue();
|
||||
public float getPathSearchRange() {
|
||||
return (float) this.pathSearchRange.getAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the given coordinates
|
||||
*/
|
||||
public NPCPath getPathToXYZ(double x, double y, double z)
|
||||
{
|
||||
public NPCPath getPathToXYZ(double x, double y, double z) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (!this.canNavigate())
|
||||
{
|
||||
if (!this.canNavigate()) {
|
||||
return null;
|
||||
}
|
||||
else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos))
|
||||
{
|
||||
} else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) {
|
||||
return this.currentPath;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.targetPos = pos;
|
||||
return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int)y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
|
||||
return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int) y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to find and set a path to XYZ. Returns true if successful.
|
||||
*/
|
||||
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_)
|
||||
{
|
||||
NPCPath pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_));
|
||||
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) {
|
||||
NPCPath pathentity = this.getPathToXYZ((double) MathHelper.floor_double(p_75492_1_), (double) ((int) p_75492_3_), (double) MathHelper.floor_double(p_75492_5_));
|
||||
return this.setPath(pathentity, p_75492_7_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the given EntityLiving
|
||||
*/
|
||||
public NPCPath getPathToEntityLiving(Entity entity)
|
||||
{
|
||||
if (!this.canNavigate())
|
||||
{
|
||||
public NPCPath getPathToEntityLiving(Entity entity) {
|
||||
if (!this.canNavigate()) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BlockPos blockpos = new BlockPos(entity);
|
||||
if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos))
|
||||
{
|
||||
if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) {
|
||||
return this.currentPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.targetPos = blockpos;
|
||||
return this.getPathEntityToEntity(this.theEntity, entity, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
|
||||
}
|
||||
@@ -203,8 +192,7 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
/**
|
||||
* Try to find and set a path to EntityLiving. Returns true if successful.
|
||||
*/
|
||||
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_)
|
||||
{
|
||||
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_) {
|
||||
NPCPath pathentity = this.getPathToEntityLiving(p_75497_1_);
|
||||
return pathentity != null && this.setPath(pathentity, p_75497_2_);
|
||||
}
|
||||
@@ -213,32 +201,23 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
* sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
|
||||
* ents and stores end coords
|
||||
*/
|
||||
public boolean setPath(@Nullable PathEntity pathEntity, double speed)
|
||||
{
|
||||
public boolean setPath(@Nullable PathEntity pathEntity, double speed) {
|
||||
NPCPath NPCPath = (NPCPath) pathEntity;
|
||||
if (NPCPath == null)
|
||||
{
|
||||
if (NPCPath == null) {
|
||||
this.currentPath = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!NPCPath.isSamePath(this.currentPath))
|
||||
{
|
||||
} else {
|
||||
if (!NPCPath.isSamePath(this.currentPath)) {
|
||||
this.currentPath = NPCPath;
|
||||
}
|
||||
|
||||
if (this.noSunPathfind)
|
||||
{
|
||||
if (this.noSunPathfind) {
|
||||
this.removeSunnyPath();
|
||||
}
|
||||
|
||||
if (this.currentPath.getCurrentPathLength() == 0)
|
||||
{
|
||||
if (this.currentPath.getCurrentPathLength() == 0) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.speed = speed;
|
||||
Vec3 vec3 = this.getEntityPosition();
|
||||
this.ticksAtLastPos = this.totalTicks;
|
||||
@@ -251,97 +230,78 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
/**
|
||||
* gets the actively used PathEntity
|
||||
*/
|
||||
public PathEntity getPath()
|
||||
{
|
||||
public PathEntity getPath() {
|
||||
return this.currentPath;
|
||||
}
|
||||
|
||||
private boolean isInLiquid()
|
||||
{
|
||||
private boolean isInLiquid() {
|
||||
return this.theEntity.isInWater() || this.theEntity.handleLavaMovement();
|
||||
}
|
||||
|
||||
private boolean canNavigate()
|
||||
{
|
||||
private boolean canNavigate() {
|
||||
return !this.isInLiquid() || (this.canSwim && this.isInLiquid());
|
||||
}
|
||||
|
||||
public void onUpdateNavigation()
|
||||
{
|
||||
public void onUpdateNavigation() {
|
||||
|
||||
++this.totalTicks;
|
||||
|
||||
if (this.tryUpdatePath)
|
||||
{
|
||||
if (this.tryUpdatePath) {
|
||||
this.updatePath();
|
||||
}
|
||||
|
||||
if (!this.noPath())
|
||||
{
|
||||
if (this.canNavigate())
|
||||
{
|
||||
if (((EntityNPCInterface)this.theEntity).display.modelSize >= 5)
|
||||
if (!this.noPath()) {
|
||||
if (this.canNavigate()) {
|
||||
if (((EntityNPCInterface) this.theEntity).display.modelSize >= 5)
|
||||
this.pathFollowBig();
|
||||
else
|
||||
this.pathFollowSmall();
|
||||
}
|
||||
else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength())
|
||||
{
|
||||
if (!this.noPath())
|
||||
{
|
||||
} else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength()) {
|
||||
if (!this.noPath()) {
|
||||
Vec3 vec3d = this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex());
|
||||
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
|
||||
|
||||
if (MathHelper.floor_double(this.theEntity.posX) == MathHelper.floor_double(vec3d.xCoord) && MathHelper.floor_double(this.theEntity.posY) == MathHelper.floor_double(vec3d.yCoord) && MathHelper.floor_double(this.theEntity.posZ) == MathHelper.floor_double(vec3d.zCoord))
|
||||
if (vec3 != null)
|
||||
{
|
||||
if (vec3 != null) {
|
||||
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
|
||||
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.noPath())
|
||||
{
|
||||
if (!this.noPath()) {
|
||||
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
|
||||
if (vec3 != null)
|
||||
{
|
||||
if (vec3 != null) {
|
||||
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pathFollowBig()
|
||||
{
|
||||
private void pathFollowBig() {
|
||||
Vec3 vec3 = this.getEntityPosition();
|
||||
int i = this.currentPath.getCurrentPathLength();
|
||||
|
||||
float f = this.theEntity.width * this.theEntity.width;
|
||||
int k;
|
||||
|
||||
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
|
||||
{
|
||||
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f)
|
||||
{
|
||||
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k) {
|
||||
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double) f) {
|
||||
this.currentPath.setCurrentPathIndex(k + 1);
|
||||
}
|
||||
}
|
||||
|
||||
k = MathHelper.floor_double(this.theEntity.width + 1.0F);
|
||||
int l = MathHelper.floor_double(this.theEntity.height + 1.0F);
|
||||
this.trimPath(vec3,i,k,l);
|
||||
this.trimPath(vec3, i, k, l);
|
||||
|
||||
this.checkForStuck(vec3);
|
||||
}
|
||||
|
||||
private void pathFollowSmall()
|
||||
{
|
||||
private void pathFollowSmall() {
|
||||
Vec3 vec3 = this.getEntityPosition();
|
||||
int i = this.currentPath.getCurrentPathLength();
|
||||
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
|
||||
{
|
||||
if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord))
|
||||
{
|
||||
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) {
|
||||
if ((double) this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord)) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
@@ -350,27 +310,24 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F;
|
||||
Vec3 vec3d1 = this.currentPath.getCurrentPos();
|
||||
|
||||
if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D)
|
||||
{
|
||||
if (MathHelper.abs((float) (this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float) (this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D) {
|
||||
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
|
||||
}
|
||||
|
||||
int k = MathHelper.ceiling_double_int(this.theEntity.width);
|
||||
int l = MathHelper.ceiling_double_int(this.theEntity.height + 1.0F);
|
||||
this.trimPath(vec3,i,k,l);
|
||||
this.trimPath(vec3, i, k, l);
|
||||
|
||||
this.checkForStuck(vec3);
|
||||
}
|
||||
|
||||
public void trimPath(Vec3 position, int pathLength, int width, int height) {
|
||||
for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
|
||||
{
|
||||
for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1) {
|
||||
Vec3 pathPoint = this.currentPath.getVectorFromIndex(this.theEntity, j1);
|
||||
if (position.distanceTo(pathPoint) > 6)
|
||||
continue;
|
||||
|
||||
if (this.isDirectPathBetweenPoints(position, pathPoint, width, height))
|
||||
{
|
||||
if (this.isDirectPathBetweenPoints(position, pathPoint, width, height)) {
|
||||
this.currentPath.setCurrentPathIndex(j1);
|
||||
break;
|
||||
}
|
||||
@@ -381,8 +338,7 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
/**
|
||||
* If null path or reached the end
|
||||
*/
|
||||
public boolean noPath()
|
||||
{
|
||||
public boolean noPath() {
|
||||
return this.currentPath == null || this.currentPath.isFinished();
|
||||
}
|
||||
|
||||
@@ -390,37 +346,30 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
* sets active PathEntity to null
|
||||
*/
|
||||
@Override
|
||||
public void clearPathEntity()
|
||||
{
|
||||
public void clearPathEntity() {
|
||||
this.currentPath = null;
|
||||
}
|
||||
|
||||
private Vec3 getEntityPosition()
|
||||
{
|
||||
private Vec3 getEntityPosition() {
|
||||
return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
||||
*/
|
||||
private double getPathableYPos()
|
||||
{
|
||||
private double getPathableYPos() {
|
||||
return this.theEntity.boundingBox.minY + 0.05D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims path data from the end to the first sun covered block
|
||||
*/
|
||||
private void removeSunnyPath()
|
||||
{
|
||||
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
|
||||
{
|
||||
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
|
||||
{
|
||||
private void removeSunnyPath() {
|
||||
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int) (this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))) {
|
||||
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) {
|
||||
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
|
||||
|
||||
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
|
||||
{
|
||||
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)) {
|
||||
this.currentPath.setCurrentPathLength(i - 1);
|
||||
return;
|
||||
}
|
||||
@@ -432,22 +381,18 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||
*/
|
||||
private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height)
|
||||
{
|
||||
Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord,startPos.yCoord, startPos.zCoord);
|
||||
Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord,endPos.yCoord, endPos.zCoord);
|
||||
private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height) {
|
||||
Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord, startPos.yCoord, startPos.zCoord);
|
||||
Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord, endPos.yCoord, endPos.zCoord);
|
||||
if (this.rayTraceBlocks(pos17, pos18, true, false, false, width, height))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height)
|
||||
{
|
||||
if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord))
|
||||
{
|
||||
if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord))
|
||||
{
|
||||
public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height) {
|
||||
if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) {
|
||||
if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) {
|
||||
int i = MathHelper.floor_double(p_147447_2_.xCoord);
|
||||
int j = MathHelper.floor_double(p_147447_2_.yCoord);
|
||||
int k = MathHelper.floor_double(p_147447_2_.zCoord);
|
||||
@@ -457,12 +402,10 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
Block block = this.worldObj.getBlock(l, i1, j1);
|
||||
int k1 = this.worldObj.getBlockMetadata(l, i1, j1);
|
||||
|
||||
if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_))
|
||||
{
|
||||
if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_)) {
|
||||
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.worldObj, l, i1, j1, p_147447_1_, p_147447_2_);
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS)
|
||||
{
|
||||
if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -470,15 +413,12 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
MovingObjectPosition movingobjectposition2 = null;
|
||||
k1 = 200;
|
||||
|
||||
while (k1-- >= 0)
|
||||
{
|
||||
if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord))
|
||||
{
|
||||
while (k1-- >= 0) {
|
||||
if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (l == i && i1 == j && j1 == k)
|
||||
{
|
||||
if (l == i && i1 == j && j1 == k) {
|
||||
if (p_147447_5_) {
|
||||
return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS;
|
||||
}
|
||||
@@ -492,42 +432,27 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
double d1 = 999.0D;
|
||||
double d2 = 999.0D;
|
||||
|
||||
if (i > l)
|
||||
{
|
||||
d0 = (double)l + 1.0D;
|
||||
}
|
||||
else if (i < l)
|
||||
{
|
||||
d0 = (double)l + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i > l) {
|
||||
d0 = (double) l + 1.0D;
|
||||
} else if (i < l) {
|
||||
d0 = (double) l + 0.0D;
|
||||
} else {
|
||||
flag6 = false;
|
||||
}
|
||||
|
||||
if (j > i1)
|
||||
{
|
||||
d1 = (double)i1 + 1.0D;
|
||||
}
|
||||
else if (j < i1)
|
||||
{
|
||||
d1 = (double)i1 + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j > i1) {
|
||||
d1 = (double) i1 + 1.0D;
|
||||
} else if (j < i1) {
|
||||
d1 = (double) i1 + 0.0D;
|
||||
} else {
|
||||
flag3 = false;
|
||||
}
|
||||
|
||||
if (k > j1)
|
||||
{
|
||||
d2 = (double)j1 + 1.0D;
|
||||
}
|
||||
else if (k < j1)
|
||||
{
|
||||
d2 = (double)j1 + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k > j1) {
|
||||
d2 = (double) j1 + 1.0D;
|
||||
} else if (k < j1) {
|
||||
d2 = (double) j1 + 0.0D;
|
||||
} else {
|
||||
flag4 = false;
|
||||
}
|
||||
|
||||
@@ -538,62 +463,45 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
double d7 = p_147447_2_.yCoord - p_147447_1_.yCoord;
|
||||
double d8 = p_147447_2_.zCoord - p_147447_1_.zCoord;
|
||||
|
||||
if (flag6)
|
||||
{
|
||||
if (flag6) {
|
||||
d3 = (d0 - p_147447_1_.xCoord) / d6;
|
||||
}
|
||||
|
||||
if (flag3)
|
||||
{
|
||||
if (flag3) {
|
||||
d4 = (d1 - p_147447_1_.yCoord) / d7;
|
||||
}
|
||||
|
||||
if (flag4)
|
||||
{
|
||||
if (flag4) {
|
||||
d5 = (d2 - p_147447_1_.zCoord) / d8;
|
||||
}
|
||||
|
||||
boolean flag5 = false;
|
||||
byte b0;
|
||||
|
||||
if (d3 < d4 && d3 < d5)
|
||||
{
|
||||
if (i > l)
|
||||
{
|
||||
if (d3 < d4 && d3 < d5) {
|
||||
if (i > l) {
|
||||
b0 = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
p_147447_1_.xCoord = d0;
|
||||
p_147447_1_.yCoord += d7 * d3;
|
||||
p_147447_1_.zCoord += d8 * d3;
|
||||
}
|
||||
else if (d4 < d5)
|
||||
{
|
||||
if (j > i1)
|
||||
{
|
||||
} else if (d4 < d5) {
|
||||
if (j > i1) {
|
||||
b0 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
p_147447_1_.xCoord += d6 * d4;
|
||||
p_147447_1_.yCoord = d1;
|
||||
p_147447_1_.zCoord += d8 * d4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k > j1)
|
||||
{
|
||||
} else {
|
||||
if (k > j1) {
|
||||
b0 = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
@@ -603,26 +511,23 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
}
|
||||
|
||||
Vec3 vec32 = Vec3.createVectorHelper(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord);
|
||||
l = (int)(vec32.xCoord = (double)MathHelper.floor_double(p_147447_1_.xCoord));
|
||||
l = (int) (vec32.xCoord = (double) MathHelper.floor_double(p_147447_1_.xCoord));
|
||||
|
||||
if (b0 == 5)
|
||||
{
|
||||
if (b0 == 5) {
|
||||
--l;
|
||||
++vec32.xCoord;
|
||||
}
|
||||
|
||||
i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(p_147447_1_.yCoord));
|
||||
i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(p_147447_1_.yCoord));
|
||||
|
||||
if (b0 == 1)
|
||||
{
|
||||
if (b0 == 1) {
|
||||
--i1;
|
||||
++vec32.yCoord;
|
||||
}
|
||||
|
||||
j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(p_147447_1_.zCoord));
|
||||
j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(p_147447_1_.zCoord));
|
||||
|
||||
if (b0 == 3)
|
||||
{
|
||||
if (b0 == 3) {
|
||||
--j1;
|
||||
++vec32.zCoord;
|
||||
}
|
||||
@@ -650,7 +555,7 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
|
||||
boolean collideCheck = (!p_147447_4_ || block2.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block2.canCollideCheck(meta2, p_147447_3_);
|
||||
boolean noCollisionBlock = block2 == Blocks.air || block2.getMaterial() == Material.lava && this.theEntity.isImmuneToFire() ||
|
||||
block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2;
|
||||
block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2;
|
||||
|
||||
if (collideCheck && !noCollisionBlock) {
|
||||
if (!block2.getBlocksMovement(this.worldObj, l, i1, j1)) {
|
||||
@@ -688,24 +593,17 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkForStuck(Vec3 positionVec3)
|
||||
{
|
||||
if (this.totalTicks - this.ticksAtLastPos > 100)
|
||||
{
|
||||
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
|
||||
{
|
||||
protected void checkForStuck(Vec3 positionVec3) {
|
||||
if (this.totalTicks - this.ticksAtLastPos > 100) {
|
||||
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D) {
|
||||
this.clearPathEntity();
|
||||
}
|
||||
|
||||
@@ -713,24 +611,20 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
this.lastPosCheck = positionVec3;
|
||||
}
|
||||
|
||||
if (this.currentPath != null && !this.currentPath.isFinished())
|
||||
{
|
||||
if (this.currentPath != null && !this.currentPath.isFinished()) {
|
||||
Vec3 vec3d = this.currentPath.getCurrentPos();
|
||||
|
||||
if (vec3d.equals(this.timeoutCachedNode))
|
||||
{
|
||||
if (vec3d.equals(this.timeoutCachedNode)) {
|
||||
this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.timeoutCachedNode = vec3d;
|
||||
double d0 = positionVec3.distanceTo(this.timeoutCachedNode);
|
||||
this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double)this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D;
|
||||
this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double) this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D;
|
||||
}
|
||||
|
||||
if (this.timeoutLimit > 0.0D && (double)this.timeoutTimer > this.timeoutLimit * 3.0D)
|
||||
{
|
||||
this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);;
|
||||
if (this.timeoutLimit > 0.0D && (double) this.timeoutTimer > this.timeoutLimit * 3.0D) {
|
||||
this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||
;
|
||||
this.timeoutTimer = 0L;
|
||||
this.timeoutLimit = 0.0D;
|
||||
this.clearPathEntity();
|
||||
@@ -740,16 +634,15 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo){
|
||||
public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo) {
|
||||
return new ChunkCache(world, blockFrom.getX(), blockFrom.getY(), blockFrom.getZ(), blockTo.getX(), blockTo.getY(), blockTo.getZ(), 0);
|
||||
}
|
||||
|
||||
public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim)
|
||||
{
|
||||
public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) {
|
||||
float f = this.getPathSearchRange();
|
||||
this.theEntity.worldObj.theProfiler.startSection("pathfind");
|
||||
BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
|
||||
int i = (int)(f + 16.0F);
|
||||
int i = (int) (f + 16.0F);
|
||||
ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i));
|
||||
this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity);
|
||||
NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, entityTo, distance);
|
||||
@@ -757,12 +650,11 @@ public class PathNavigateFlying extends PathNavigate {
|
||||
return pathentity;
|
||||
}
|
||||
|
||||
public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim)
|
||||
{
|
||||
public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) {
|
||||
float f = this.getPathSearchRange();
|
||||
this.theEntity.worldObj.theProfiler.startSection("pathfind");
|
||||
BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
|
||||
int i = (int)(f + 16.0F);
|
||||
int i = (int) (f + 16.0F);
|
||||
ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i));
|
||||
this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity);
|
||||
NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ(), f);
|
||||
|
||||
Reference in new issue
Block a user