本文整理汇总了Java中net.minecraft.pathfinding.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于net.minecraft.pathfinding包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPath
import net.minecraft.pathfinding.Path; //导入依赖的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: canEasilyReach
import net.minecraft.pathfinding.Path; //导入依赖的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;
}
示例3: canEasilyReach
import net.minecraft.pathfinding.Path; //导入依赖的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;
}
}
}
示例4: getJumpUpwardsMotion
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
protected float getJumpUpwardsMotion()
{
if (!this.isCollidedHorizontally && (!this.moveHelper.isUpdating() || this.moveHelper.getY() <= this.posY + 0.5D))
{
Path path = this.navigator.getPath();
if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength())
{
Vec3d vec3d = path.getPosition(this);
if (vec3d.yCoord > this.posY + 0.5D)
{
return 0.5F;
}
}
return this.moveHelper.getSpeed() <= 0.6D ? 0.2F : 0.3F;
}
else
{
return 0.5F;
}
}
示例5: makePath
import net.minecraft.pathfinding.Path; //导入依赖的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);
}
示例6: renderPathLine
import net.minecraft.pathfinding.Path; //导入依赖的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();
}
示例7: canEasilyReach
import net.minecraft.pathfinding.Path; //导入依赖的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;
}
}
}
示例8: getJumpUpwardsMotion
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
protected float getJumpUpwardsMotion()
{
if (!this.isCollidedHorizontally && (!this.moveHelper.isUpdating() || this.moveHelper.getY() <= this.posY + 0.5D))
{
Path path = this.navigator.getPath();
if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength())
{
Vec3d vec3d = path.getPosition(this);
if (vec3d.yCoord > this.posY)
{
return 0.5F;
}
}
return this.moveHelper.getSpeed() <= 0.6D ? 0.2F : 0.3F;
}
else
{
return 0.5F;
}
}
示例9: updateTask
import net.minecraft.pathfinding.Path; //导入依赖的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)));
}
示例10: shouldExecute
import net.minecraft.pathfinding.Path; //导入依赖的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;
}
示例11: func_190067_a
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
public void func_190067_a(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.func_190066_a(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.field_190069_f + 0.5D, (double)pathpoint.yCoord - this.field_190070_g + 0.5D, (double)pathpoint.zCoord - this.field_190071_h + 0.5D).color(k, l, i1, 255).endVertex();
}
}
tessellator.draw();
}
示例12: getPathToEntityLiving
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
/**
* Returns the path to the given EntityLiving
*/
@Override
public Path getPathToEntityLiving(Entity par1Entity) {
BlockPos pos = new BlockPos(par1Entity.posX, par1Entity.getEntityBoundingBox().minY, par1Entity.posZ);
if (par1Entity instanceof EntityItem && !pathfindingEntity.isBlockValidPathfindBlock(pos)) {
// items can end up with a blockpos of the ground they're sitting on,
// which will prevent the drone pathfinding to them
if (pathfindingEntity.isBlockValidPathfindBlock(pos.up())) {
pos = pos.up();
}
}
return getPathToPos(pos);
}
示例13: getPathToPos
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
@Nullable
@Override
public Path getPathToPos(BlockPos pos) {
telPos = pos;
if (forceTeleport) {
teleportCounter = 0;
return null;
}
if (!pathfindingEntity.isBlockValidPathfindBlock(pos) || pathfindingEntity.getDistanceSqToCenter(pos) < 0.3)
return null;
pathfindingEntity.setStandby(false);
teleportCounter = -1;
Path path = super.getPathToPos(pos);
//Only paths that actually end up where we want to are valid, not just halfway.
if(path != null){
PathPoint lastPoint = path.getFinalPathPoint();
if(lastPoint != null && (lastPoint.x != pos.getX() || lastPoint.y != pos.getY() || lastPoint.z != pos.getZ())){
path = null;
}
}
if (path == null) {
teleportCounter = 0;
}
return path;
}
示例14: shouldExecute
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theEntity.isCollidedHorizontally)
{
return false;
}
else
{
PathNavigateGround pathnavigateground = (PathNavigateGround)this.theEntity.getNavigator();
Path path = pathnavigateground.getPath();
if (path != null && !path.isFinished() && pathnavigateground.getEnterDoors())
{
for (int i = 0; i < Math.min(path.getCurrentPathIndex() + 2, path.getCurrentPathLength()); ++i)
{
PathPoint pathpoint = path.getPathPointFromIndex(i);
this.doorPosition = new BlockPos(pathpoint.xCoord, pathpoint.yCoord + 1, pathpoint.zCoord);
if (this.theEntity.getDistanceSq((double)this.doorPosition.getX(), this.theEntity.posY, (double)this.doorPosition.getZ()) <= 2.25D)
{
this.doorBlock = this.getBlockDoor(this.doorPosition);
if (this.doorBlock != null)
{
return true;
}
}
}
this.doorPosition = (new BlockPos(this.theEntity)).up();
this.doorBlock = this.getBlockDoor(this.doorPosition);
return this.doorBlock != null;
}
else
{
return false;
}
}
}
示例15: getPath
import net.minecraft.pathfinding.Path; //导入依赖的package包/类
public Path getPath() {
List<Node> nodes = run();
if (nodes == null || nodes.size() <= 0) {
return null;
}
PathPoint[] pathPoints = new PathPoint[nodes.size()];
for (int i = 0; i < pathPoints.length; i++) {
pathPoints[i] = nodes.get(nodes.size() - i - 1).toPathPoint();
}
return new Path(pathPoints);
}