當前位置: 首頁>>代碼示例>>Java>>正文


Java PathNavigate.getPath方法代碼示例

本文整理匯總了Java中net.minecraft.pathfinding.PathNavigate.getPath方法的典型用法代碼示例。如果您正苦於以下問題:Java PathNavigate.getPath方法的具體用法?Java PathNavigate.getPath怎麽用?Java PathNavigate.getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.pathfinding.PathNavigate的用法示例。


在下文中一共展示了PathNavigate.getPath方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldExecute

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的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

示例2: updateTask

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
public void updateTask() {
    PathNavigate navigator = this.miner.getNavigator();
    if (navigator.getPath() != null && navigator.getPath().isFinished()) {
        if (this.currentMiningTime > 0) {
            this.currentMiningTime--;
        }
        else {
            int x = this.oreLocation.x;
            int y = this.oreLocation.y;
            int z = this.oreLocation.z;
            World world = this.miner.worldObj;
            Block block = world.getBlock(x, y, z);
            if (shouldMineBlock(block, x, y, z)) {
                System.out.println("Miner " + this.miner.getEntityId() + " mined ore!");
                ArrayList<ItemStack> items = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
                for (ItemStack item : items) {
                    InventoryUtils.addToInventory(item, this.miner.inventory);
                }
                world.setBlockToAir(x, y, z);
                navigator.clearPathEntity();
                this.miner.swingItem();
            }
        }
    }
}
 
開發者ID:civilframe,項目名稱:TameHumans,代碼行數:26,代碼來源:EntityAIMineOre.java

示例3: shouldExecute

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
@Override
public boolean shouldExecute() {
	if (!theEntity.isCollidedHorizontally)
		return false;
	else {
		PathNavigate pathnavigate = theEntity.getNavigator();
		PathEntity pathentity = pathnavigate.getPath();

		if (pathentity != null && !pathentity.isFinished() && pathnavigate.getCanBreakDoors()) {
			for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i) {
				PathPoint pathpoint = pathentity.getPathPointFromIndex(i);
				entityPosX = pathpoint.xCoord;
				entityPosY = pathpoint.yCoord + 1;
				entityPosZ = pathpoint.zCoord;

				if (theEntity.getDistanceSq(entityPosX, theEntity.posY, entityPosZ) <= 2.25D) {
					field_151504_e = func_151503_a(entityPosX, entityPosY, entityPosZ);

					if (field_151504_e != null)
						return true;
				}
			}

			entityPosX = MathHelper.floor_double(theEntity.posX);
			entityPosY = MathHelper.floor_double(theEntity.posY + 1.0D);
			entityPosZ = MathHelper.floor_double(theEntity.posZ);
			field_151504_e = func_151503_a(entityPosX, entityPosY, entityPosZ);
			return field_151504_e != null;
		} else
			return false;
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:33,代碼來源:EntityAICustomDoorInteract.java

示例4: renderNavigation

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的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

示例5: updateTask

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
public void updateTask()
    {
//        float f = (float)((double)((float)this.entityPosX + 0.5F) - this.entity.posX);
//        float f1 = (float)((double)((float)this.entityPosZ + 0.5F) - this.entity.posZ);
//        float f2 = this.entityPositionX * f + this.entityPositionZ * f1;
//
//        if (f2 < 0.0F)
//        {
//            this.hasStoppedDoorInteraction = true;
//        }
    	
    	PathNavigate pathnavigate = this.entity.getNavigator();
        PathEntity pathentity = pathnavigate.getPath();

        if (pathentity != null && !pathentity.isFinished())
        {
            for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i)
            {
                PathPoint pathpoint = pathentity.getPathPointFromIndex(i);
                this.doorPosX = pathpoint.xCoord;
                this.doorPosY = pathpoint.yCoord + 1;
                this.doorPosZ = pathpoint.zCoord;

                if (this.entity.getDistanceSq((double)this.doorPosX, this.entity.posY, (double)this.doorPosZ) <= 2.25D)
                {
                    this.door = this.getDoorObject(this.doorPosX, this.doorPosY, this.doorPosZ);
                }
            }

            this.doorPosX = MathHelper.floor_double(this.entity.posX);
            this.doorPosY = MathHelper.floor_double(this.entity.posY + 1.0D);
            this.doorPosZ = MathHelper.floor_double(this.entity.posZ);
            this.door = this.getDoorObject(this.doorPosX, this.doorPosY, this.doorPosZ);
        }
    	
    	if (door != null)
    	{
    		entity.worldObj.playAuxSFX(2001, doorPosX, doorPosY, doorPosZ, Block.getIdFromBlock(door));
    		entity.worldObj.setBlockToAir(doorPosX, doorPosY, doorPosZ);
    		door = null;
    	}
    }
 
開發者ID:Link1234Gamer,項目名稱:FiveNightsAtFreddysUniverseMod,代碼行數:43,代碼來源:EntityCandyAIBreakDoor.java

示例6: shouldExecute

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (!this.theEntity.isCollidedHorizontally)
    {
        return false;
    }
    else
    {
        PathNavigate var1 = this.theEntity.getNavigator();
        PathEntity var2 = var1.getPath();

        if (var2 != null && !var2.isFinished() && var1.getCanBreakDoors())
        {
            for (int var3 = 0; var3 < Math.min(var2.getCurrentPathIndex() + 2, var2.getCurrentPathLength()); ++var3)
            {
                PathPoint var4 = var2.getPathPointFromIndex(var3);
                this.entityPosX = var4.xCoord;
                this.entityPosY = var4.yCoord + 1;
                this.entityPosZ = var4.zCoord;

                if (this.theEntity.getDistanceSq((double)this.entityPosX, this.theEntity.posY, (double)this.entityPosZ) <= 2.25D)
                {
                    this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ);

                    if (this.field_151504_e != null)
                    {
                        return true;
                    }
                }
            }

            this.entityPosX = MathHelper.floor_double(this.theEntity.posX);
            this.entityPosY = MathHelper.floor_double(this.theEntity.posY + 1.0D);
            this.entityPosZ = MathHelper.floor_double(this.theEntity.posZ);
            this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ);
            return this.field_151504_e != null;
        }
        else
        {
            return false;
        }
    }
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:47,代碼來源:EntityAIDoorInteract.java

示例7: shouldExecute

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (!this.theEntity.isCollidedHorizontally)
    {
        return false;
    }
    else
    {
        PathNavigate pathnavigate = this.theEntity.getNavigator();
        PathEntity pathentity = pathnavigate.getPath();

        if (pathentity != null && !pathentity.isFinished() && pathnavigate.getCanBreakDoors())
        {
            for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i)
            {
                PathPoint pathpoint = pathentity.getPathPointFromIndex(i);
                this.entityPosX = pathpoint.xCoord;
                this.entityPosY = pathpoint.yCoord + 1;
                this.entityPosZ = pathpoint.zCoord;

                if (this.theEntity.getDistanceSq((double)this.entityPosX, this.theEntity.posY, (double)this.entityPosZ) <= 2.25D)
                {
                    this.targetDoor = this.findUsableDoor(this.entityPosX, this.entityPosY, this.entityPosZ);

                    if (this.targetDoor != null)
                    {
                        return true;
                    }
                }
            }

            this.entityPosX = MathHelper.floor_double(this.theEntity.posX);
            this.entityPosY = MathHelper.floor_double(this.theEntity.posY + 1.0D);
            this.entityPosZ = MathHelper.floor_double(this.theEntity.posZ);
            this.targetDoor = this.findUsableDoor(this.entityPosX, this.entityPosY, this.entityPosZ);
            return this.targetDoor != null;
        }
        else
        {
            return false;
        }
    }
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:47,代碼來源:EntityAIUseDoorMF.java

示例8: shouldExecute

import net.minecraft.pathfinding.PathNavigate; //導入方法依賴的package包/類
public boolean shouldExecute()
{
    if (!this.theEntity.isCollidedHorizontally)
    {
        return false;
    }
    else
    {
        PathNavigate pathnavigate = this.theEntity.getNavigator();
        PathEntity pathentity = pathnavigate.getPath();

        if (pathentity != null && !pathentity.isFinished() && pathnavigate.getCanBreakDoors())
        {
            for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i)
            {
                PathPoint pathpoint = pathentity.getPathPointFromIndex(i);
                this.entityPosX = pathpoint.xCoord;
                this.entityPosY = pathpoint.yCoord + 1;
                this.entityPosZ = pathpoint.zCoord;

                if (this.theEntity.getDistanceSq((double)this.entityPosX, this.theEntity.posY, (double)this.entityPosZ) <= 2.25D)
                {
                    this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ);

                    if (this.field_151504_e != null)
                    {
                        return true;
                    }
                }
            }

            this.entityPosX = MathHelper.floor_double(this.theEntity.posX);
            this.entityPosY = MathHelper.floor_double(this.theEntity.posY + 1.0D);
            this.entityPosZ = MathHelper.floor_double(this.theEntity.posZ);
            this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ);
            return this.field_151504_e != null;
        }
        else
        {
            return false;
        }
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:44,代碼來源:EntityAIDoorInteract.java


注:本文中的net.minecraft.pathfinding.PathNavigate.getPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。