当前位置: 首页>>代码示例>>Java>>正文


Java Path类代码示例

本文整理汇总了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);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:PathfinderDrone.java

示例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;
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:21,代码来源:EntityAITreater.java

示例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;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:EntityAITarget.java

示例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;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityRabbit.java

示例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);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:EntityDragon.java

示例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();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:DebugRendererPathfinding.java

示例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;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:EntityAITarget.java

示例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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:EntityRabbit.java

示例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)));
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:22,代码来源:MobSlime.java

示例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;
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:24,代码来源:EntityAIEatMeat.java

示例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();
}
 
开发者ID:BlazeAxtrius,项目名称:ExpandedRailsMod,代码行数:24,代码来源:DebugRendererPathfinding.java

示例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);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:EntityPathNavigateDrone.java

示例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;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:30,代码来源:EntityPathNavigateDrone.java

示例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;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:EntityAIDoorInteract.java

示例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);
}
 
开发者ID:InfinityRaider,项目名称:SettlerCraft,代码行数:12,代码来源:AStar.java


注:本文中的net.minecraft.pathfinding.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。