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


Java Path.getFinalPathPoint方法代码示例

本文整理汇总了Java中net.minecraft.pathfinding.Path.getFinalPathPoint方法的典型用法代码示例。如果您正苦于以下问题:Java Path.getFinalPathPoint方法的具体用法?Java Path.getFinalPathPoint怎么用?Java Path.getFinalPathPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.pathfinding.Path的用法示例。


在下文中一共展示了Path.getFinalPathPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例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_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

示例4: 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

示例5: 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

示例6: renderNavigation

import net.minecraft.pathfinding.Path; //导入方法依赖的package包/类
private void renderNavigation() {
    text.setOrigin(16, 32);
    
    text.setColor(YELLOW);
    text.println("Navigation (Ground)");
    text.setColor(WHITE);
    
    PathNavigate nav = dragonServer.getNavigator();
    PathNavigateGround pathNavigateGround = null;
    if (nav instanceof PathNavigateGround) {
        pathNavigateGround = (PathNavigateGround) nav;
    }
    
    text.println("Search range: " + nav.getPathSearchRange());
    text.println("Can swim: " + (pathNavigateGround == null ? "N/A" : pathNavigateGround.getCanSwim()));
    text.println("Break doors: " + (pathNavigateGround == null ? "N/A" : pathNavigateGround.getEnterDoors()));
    text.println("No path: " + nav.noPath());

    Path path = nav.getPath();
    
    if (path != null) {
        text.println("Length: " + path.getCurrentPathLength());
        text.println("Index: " + path.getCurrentPathIndex());
        
        PathPoint finalPoint = path.getFinalPathPoint();
        text.println("Final point: " + finalPoint);
    }
    
    text.println();

    text.setColor(YELLOW);
    text.println("Navigation (Air)");
    text.setColor(WHITE);
    
    text.println("Can fly: " + dragonClient.canFly());
    text.println("Flying: " + dragonClient.isFlying());
    text.println("Altitude: " + dfLong.format(dragonClient.getAltitude()));
}
 
开发者ID:ata4,项目名称:dragon-mounts,代码行数:39,代码来源:GuiDragonDebug.java


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