本文整理汇总了Java中net.minecraft.pathfinding.PathPoint类的典型用法代码示例。如果您正苦于以下问题:Java PathPoint类的具体用法?Java PathPoint怎么用?Java PathPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathPoint类属于net.minecraft.pathfinding包,在下文中一共展示了PathPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPath
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Returns a new PathEntity for a given start and end point
*/
private Path createPath(PathPoint start, PathPoint end)
{
int i = 1;
for (PathPoint pathpoint = end; pathpoint.previous != null; pathpoint = pathpoint.previous)
{
++i;
}
PathPoint[] apathpoint = new PathPoint[i];
PathPoint pathpoint1 = end;
--i;
for (apathpoint[i] = end; pathpoint1.previous != null; apathpoint[i] = pathpoint1)
{
pathpoint1 = pathpoint1.previous;
--i;
}
return new Path(apathpoint);
}
示例2: findPathOptions
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
{
int i = 0;
for (EnumFacing enumfacing : EnumFacing.values())
{
PathPoint pathpoint = this.getSafePoint(entityIn, currentPoint.xCoord + enumfacing.getFrontOffsetX(), currentPoint.yCoord + enumfacing.getFrontOffsetY(), currentPoint.zCoord + enumfacing.getFrontOffsetZ());
if (pathpoint != null && !pathpoint.visited && pathpoint.distanceTo(targetPoint) < maxDistance)
{
pathOptions[i++] = pathpoint;
}
}
return i;
}
示例3: getPathPointTo
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Returns given entity's position as PathPoint
*/
public PathPoint getPathPointTo(Entity entityIn)
{
int i;
if (this.canSwim && entityIn.isInWater())
{
i = (int)entityIn.getEntityBoundingBox().minY;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.flowing_water || block == Blocks.water; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock())
{
++i;
blockpos$mutableblockpos.func_181079_c(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
}
this.avoidsWater = false;
}
else
{
i = MathHelper.floor_double(entityIn.getEntityBoundingBox().minY + 0.5D);
}
return this.openPoint(MathHelper.floor_double(entityIn.getEntityBoundingBox().minX), i, MathHelper.floor_double(entityIn.getEntityBoundingBox().minZ));
}
示例4: canEasilyReach
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Checks to see if this entity can find a short path to the given target.
*/
private boolean canEasilyReach(EntityLivingBase p_75295_1_)
{
this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
PathEntity pathentity = this.taskOwner.getNavigator().getPathToEntityLiving(p_75295_1_);
if (pathentity == null)
{
return false;
}
else
{
PathPoint pathpoint = pathentity.getFinalPathPoint();
if (pathpoint == null)
{
return false;
}
else
{
int i = pathpoint.xCoord - MathHelper.floor_double(p_75295_1_.posX);
int j = pathpoint.zCoord - MathHelper.floor_double(p_75295_1_.posZ);
return (double)(i * i + j * j) <= 2.25D;
}
}
}
示例5: canEasilyReach
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Checks to see if this entity can find a short path to the given target.
* Copied from {@link net.minecraft.entity.ai.EntityAITarget#canEasilyReach}.
*
*/
private boolean canEasilyReach(EntityItem entity)
{
Path path = this.taskOwner.getNavigator().getPathToEntityLiving(entity);
if (path != null)
{
PathPoint pathpoint = path.getFinalPathPoint();
if (pathpoint != null)
{
int x = pathpoint.x - MathHelper.floor(entity.posX);
int z = pathpoint.z - MathHelper.floor(entity.posZ);
return (double)(x * x + z * z) <= 2.25D;
}
}
return false;
}
示例6: canEasilyReach
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Checks to see if this entity can find a short path to the given target.
*/
private boolean canEasilyReach(EntityLivingBase target)
{
this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
Path path = this.taskOwner.getNavigator().getPathToEntityLiving(target);
if (path == null)
{
return false;
}
else
{
PathPoint pathpoint = path.getFinalPathPoint();
if (pathpoint == null)
{
return false;
}
else
{
int i = pathpoint.xCoord - MathHelper.floor(target.posX);
int j = pathpoint.zCoord - MathHelper.floor(target.posZ);
return (double)(i * i + j * j) <= 2.25D;
}
}
}
示例7: setTarget
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
public void setTarget(EntityLivingBase p_188686_1_)
{
this.attackTarget = p_188686_1_;
int i = this.dragon.initPathPoints();
int j = this.dragon.getNearestPpIdx(this.attackTarget.posX, this.attackTarget.posY, this.attackTarget.posZ);
int k = MathHelper.floor(this.attackTarget.posX);
int l = MathHelper.floor(this.attackTarget.posZ);
double d0 = (double)k - this.dragon.posX;
double d1 = (double)l - this.dragon.posZ;
double d2 = (double)MathHelper.sqrt(d0 * d0 + d1 * d1);
double d3 = Math.min(0.4000000059604645D + d2 / 80.0D - 1.0D, 10.0D);
int i1 = MathHelper.floor(this.attackTarget.posY + d3);
PathPoint pathpoint = new PathPoint(k, i1, l);
this.currentPath = this.dragon.findPath(i, j, pathpoint);
if (this.currentPath != null)
{
this.currentPath.incrementPathIndex();
this.navigateToNextPathNode();
}
}
示例8: makePath
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Create and return a new PathEntity defining a path from the start to the finish, using the connections already
* made by the caller, findPath.
*/
private Path makePath(PathPoint start, PathPoint finish)
{
int i = 1;
for (PathPoint pathpoint = finish; pathpoint.previous != null; pathpoint = pathpoint.previous)
{
++i;
}
PathPoint[] apathpoint = new PathPoint[i];
PathPoint pathpoint1 = finish;
--i;
for (apathpoint[i] = finish; pathpoint1.previous != null; apathpoint[i] = pathpoint1)
{
pathpoint1 = pathpoint1.previous;
--i;
}
return new Path(apathpoint);
}
示例9: renderPathLine
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
public void renderPathLine(float p_190067_1_, Path p_190067_2_)
{
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
for (int i = 0; i < p_190067_2_.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = p_190067_2_.getPathPointFromIndex(i);
if (this.addDistanceToPlayer(pathpoint) <= 40.0F)
{
float f = (float)i / (float)p_190067_2_.getCurrentPathLength() * 0.33F;
int j = i == 0 ? 0 : MathHelper.hsvToRGB(f, 0.9F, 0.9F);
int k = j >> 16 & 255;
int l = j >> 8 & 255;
int i1 = j & 255;
vertexbuffer.pos((double)pathpoint.xCoord - this.xo + 0.5D, (double)pathpoint.yCoord - this.yo + 0.5D, (double)pathpoint.zCoord - this.zo + 0.5D).color(k, l, i1, 255).endVertex();
}
}
tessellator.draw();
}
示例10: canEasilyReach
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
/**
* Checks to see if this entity can find a short path to the given target.
*/
private boolean canEasilyReach(EntityLivingBase target)
{
this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
Path path = this.taskOwner.getNavigator().getPathToEntityLiving(target);
if (path == null)
{
return false;
}
else
{
PathPoint pathpoint = path.getFinalPathPoint();
if (pathpoint == null)
{
return false;
}
else
{
int i = pathpoint.xCoord - MathHelper.floor_double(target.posX);
int j = pathpoint.zCoord - MathHelper.floor_double(target.posZ);
return (double)(i * i + j * j) <= 2.25D;
}
}
}
示例11: setTarget
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
public void setTarget(EntityLivingBase p_188686_1_)
{
this.attackTarget = p_188686_1_;
int i = this.dragon.initPathPoints();
int j = this.dragon.getNearestPpIdx(this.attackTarget.posX, this.attackTarget.posY, this.attackTarget.posZ);
int k = MathHelper.floor_double(this.attackTarget.posX);
int l = MathHelper.floor_double(this.attackTarget.posZ);
double d0 = (double)k - this.dragon.posX;
double d1 = (double)l - this.dragon.posZ;
double d2 = (double)MathHelper.sqrt_double(d0 * d0 + d1 * d1);
double d3 = Math.min(0.4000000059604645D + d2 / 80.0D - 1.0D, 10.0D);
int i1 = MathHelper.floor_double(this.attackTarget.posY + d3);
PathPoint pathpoint = new PathPoint(k, i1, l);
this.currentPath = this.dragon.findPath(i, j, pathpoint);
if (this.currentPath != null)
{
this.currentPath.incrementPathIndex();
this.navigateToNextPathNode();
}
}
示例12: updateTask
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
@Override
public void updateTask()
{
Path path = this.slime.getNavigator().getPath();
if (path == null)
{
this.slime.getNavigator().clearPathEntity();
return;
}
PathPoint point = path.getPathPointFromIndex(path.getCurrentPathIndex());
double xDir = (point.x+ 0.5) - this.slime.posX;
double zDir = (point.z+ 0.5) - this.slime.posZ;
MobSlime.SlimeMoveHelper moveHelper = (MobSlime.SlimeMoveHelper) this.slime.getMoveHelper();
moveHelper.setDirection((float) MathHelper.atan2(zDir, xDir), false);
moveHelper.setSpeed(1);
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(""));
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Target X: " + Integer.toString(point.x)));
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Target Z: " + Integer.toString(point.z)));
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Current X: " + Integer.toString((int) this.slime.posX)));
Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Current Z: " + Integer.toString((int) this.slime.posZ)));
}
示例13: shouldExecute
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
@Override
public boolean shouldExecute() {
if (living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > living.ticksExisted)
living.getEntityData().setInteger(NBT_KEY_LAST_MEAL, -Time.DAY);
PathNavigate navigate = living.getNavigator();
if (living.getHealth() < living.getMaxHealth() || living.ticksExisted - living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > Time.DAY) {
List<EntityItem> list = living.world.getEntitiesWithinAABB(EntityItem.class, AABBHelper.getAABBFromEntity(living, 32), this);
list.sort(this);
for (int i = list.size() - 1; i > -1; i--) {
EntityItem item = list.get(i);
navigate.tryMoveToEntityLiving(item, 1);
Path path = navigate.getPath();
if (path != null) {
PathPoint point = path.getFinalPathPoint();
if (item.getPosition().distanceSq(new Vec3i(point.x, point.y, point.z)) < 2) {
meat = item;
return true;
}
}
}
}
return false;
}
示例14: findPathOptions
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
@Override
public int findPathOptions(PathPoint[] pathOptions, Entity entity, PathPoint currentPoint, PathPoint targetPoint, float maxDistance) {
if (hash == -1) {
hash = entity.getUniqueID().hashCode();
if (hash == -1) hash = 0;
}
int nodes = 0;
BlockPos.MutableBlockPos at = new BlockPos.MutableBlockPos(0, 0, 0);
for (EnumFacing side : EnumFacing.VALUES) {
int x = currentPoint.xCoord + side.getFrontOffsetX();
int y = currentPoint.yCoord + side.getFrontOffsetY();
int z = currentPoint.zCoord + side.getFrontOffsetZ();
int sum = x + y + z + hash;
if (sum % 2 == 0) continue;
at.set(x, y, z);
if (!isSafe(entity.worldObj, at)) continue;
pathOptions[nodes++] = openPoint(x, y, z);
}
return nodes;
}
示例15: canEasilyReach
import net.minecraft.pathfinding.PathPoint; //导入依赖的package包/类
private boolean canEasilyReach(EntityLivingBase p_75295_1_)
{
this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
PathEntity pathentity = this.taskOwner.getNavigator().getPathToEntityLiving(p_75295_1_);
if (pathentity == null)
{
return false;
}
else
{
PathPoint pathpoint = pathentity.getFinalPathPoint();
if (pathpoint == null)
{
return false;
}
else
{
int i = pathpoint.xCoord - MathHelper.floor_double(p_75295_1_.posX);
int j = pathpoint.zCoord - MathHelper.floor_double(p_75295_1_.posZ);
return (double)(i * i + j * j) <= 2.25D;
}
}
}