base mod created
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.pathfinding;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PathNavigateSwimmer extends PathNavigate
|
||||
{
|
||||
public PathNavigateSwimmer(EntityLiving entitylivingIn, World worldIn)
|
||||
{
|
||||
super(entitylivingIn, worldIn);
|
||||
}
|
||||
|
||||
protected PathFinder getPathFinder()
|
||||
{
|
||||
return new PathFinder(new SwimNodeProcessor());
|
||||
}
|
||||
|
||||
/**
|
||||
* If on ground or swimming and can swim
|
||||
*/
|
||||
protected boolean canNavigate()
|
||||
{
|
||||
return this.isInLiquid();
|
||||
}
|
||||
|
||||
protected Vec3d getEntityPosition()
|
||||
{
|
||||
return new Vec3d(this.entity.posX, this.entity.posY + (double)this.entity.height * 0.5D, this.entity.posZ);
|
||||
}
|
||||
|
||||
protected void pathFollow()
|
||||
{
|
||||
Vec3d vec3d = this.getEntityPosition();
|
||||
float f = this.entity.width * this.entity.width;
|
||||
int i = 6;
|
||||
|
||||
if (vec3d.squareDistanceTo(this.currentPath.getVectorFromIndex(this.entity, this.currentPath.getCurrentPathIndex())) < (double)f)
|
||||
{
|
||||
this.currentPath.incrementPathIndex();
|
||||
}
|
||||
|
||||
for (int j = Math.min(this.currentPath.getCurrentPathIndex() + 6, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j)
|
||||
{
|
||||
Vec3d vec3d1 = this.currentPath.getVectorFromIndex(this.entity, j);
|
||||
|
||||
if (vec3d1.squareDistanceTo(vec3d) <= 36.0D && this.isDirectPathBetweenPoints(vec3d, vec3d1, 0, 0, 0))
|
||||
{
|
||||
this.currentPath.setCurrentPathIndex(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.checkForStuck(vec3d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified entity can safely walk to the specified location.
|
||||
*/
|
||||
protected boolean isDirectPathBetweenPoints(Vec3d posVec31, Vec3d posVec32, int sizeX, int sizeY, int sizeZ)
|
||||
{
|
||||
RayTraceResult raytraceresult = this.world.rayTraceBlocks(posVec31, new Vec3d(posVec32.x, posVec32.y + (double)this.entity.height * 0.5D, posVec32.z), false, true, false);
|
||||
return raytraceresult == null || raytraceresult.typeOfHit == RayTraceResult.Type.MISS;
|
||||
}
|
||||
|
||||
public boolean canEntityStandOnPos(BlockPos pos)
|
||||
{
|
||||
return !this.world.getBlockState(pos).isFullBlock();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user