net.minecraft.pathfinding.PathEntity Java Examples
The following examples show how to use
net.minecraft.pathfinding.PathEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityPathNavigateDrone.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private PathEntity getPathEntityToEntity(EntityDrone par1Entity, Entity par2Entity, float par3, boolean par4, boolean par5, boolean par6, boolean par7){ /* int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY + 1.0D); int k = MathHelper.floor_double(par1Entity.posZ); int l = (int)(par3 + 16.0F); int i1 = i - l; int j1 = j - l; int k1 = k - l; int l1 = i + l; int i2 = j + l; int j2 = k + l; ChunkCache chunkcache = new ChunkCache(par1Entity.worldObj, i1, j1, k1, l1, i2, j2, 0); PathEntity pathentity = new PathFinderDrone(par1Entity, chunkcache, par4, par5, pathThroughLiquid, par7).createEntityPathTo(par1Entity, par2Entity, par3); return pathentity;*/ return getEntityPathToXYZ(par1Entity, (int)Math.floor(par2Entity.posX), (int)Math.floor(par2Entity.posY), (int)Math.floor(par2Entity.posZ), par3, par4, par5, par6, par7); }
Example #2
Source File: AIUncheckedAttackOnCollide.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean shouldExecute() { EntityLivingBase target = golem.getAttackTarget(); if (target == null) { return false; } PathEntity pathEntity = golem.getNavigator().getPathToEntityLiving(target); if(pathEntity != null) { INJECTOR.setObject(this); INJECTOR.setField("entityPathEntity", pathEntity); INJECTOR.setField("entityTarget", target); return true; } return false; }
Example #3
Source File: MoCEntityAnimal.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
private void followPlayer() { EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, 24D); if (entityplayer1 == null) { return; } ItemStack itemstack1 = entityplayer1.inventory.getCurrentItem(); if (itemstack1 != null && isMyFavoriteFood(itemstack1)) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entityplayer1, 16F, true, false, false, true); setPathToEntity(pathentity); } }
Example #4
Source File: EntityPathNavigateDrone.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public PathEntity getEntityPathToXYZ(EntityDrone par1Entity, int par2, int par3, int par4, float par5, boolean par6, boolean par7, boolean par8, boolean par9){ if(!par1Entity.isBlockValidPathfindBlock(par2, par3, par4)) return null; PathEntity pathentity = null; int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posY); int j1 = MathHelper.floor_double(par1Entity.posZ); if(!forceTeleport || l == par2 && i1 == par3 && j1 == par4) { int k1 = (int)(par5 + 8.0F); int l1 = l - k1; int i2 = i1 - k1; int j2 = j1 - k1; int k2 = l + k1; int l2 = i1 + k1; int i3 = j1 + k1; ChunkCache chunkcache = new ChunkCache(par1Entity.worldObj, l1, i2, j2, k2, l2, i3, 0); pathentity = new PathFinderDrone(par1Entity, chunkcache, par6, par7, pathThroughLiquid, par9).createEntityPathTo(par1Entity, par2, par3, par4, par5); if(pathentity != null) { PathPoint finalPoint = pathentity.getFinalPathPoint(); if(finalPoint == null || finalPoint.xCoord != par2 || finalPoint.yCoord != par3 || finalPoint.zCoord != par4) pathentity = null; } } teleportCounter = pathentity != null ? -1 : 0; telX = par2; telY = par3; telZ = par4; par1Entity.setStandby(false); return pathentity; }
Example #5
Source File: HackableTameable.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onHackFinished(Entity entity, EntityPlayer player){ EntityTameable tameable = (EntityTameable)entity; if(entity.worldObj.isRemote) { tameable.handleHealthUpdate((byte)7); } else { tameable.setPathToEntity((PathEntity)null); tameable.setAttackTarget((EntityLivingBase)null); tameable.setHealth(20.0F); tameable.func_152115_b(player.getUniqueID().toString());//setOwner entity.worldObj.setEntityState(tameable, (byte)7); tameable.setTamed(true); } }
Example #6
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public static void MoveCreatureToXYZ(EntityCreature movingEntity, int x, int y, int z, float f) { //PathEntity pathentity = MoCreatures.mc.theWorld.getEntityPathToXYZ(movingEntity, x, y, z, f); //pathToEntity = worldObj.getEntityPathToXYZ(this, i, j, k, 10F, true, false, false, true); //TODO works? PathEntity pathentity = movingEntity.worldObj.getEntityPathToXYZ(movingEntity, x, y, z, f, true, false, false, true); if (pathentity != null) { movingEntity.setPathToEntity(pathentity); } }
Example #7
Source File: MoCEntityMob.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
protected void getPathOrWalkableBlock(Entity entity, float f) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true); if ((pathentity == null) && (f > 12F)) { int i = MathHelper.floor_double(entity.posX) - 2; int j = MathHelper.floor_double(entity.posZ) - 2; int k = MathHelper.floor_double(entity.boundingBox.minY); for (int l = 0; l <= 4; l++) { for (int i1 = 0; i1 <= 4; i1++) { if (((l < 1) || (i1 < 1) || (l > 3) || (i1 > 3)) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1)) { setLocationAndAngles((i + l) + 0.5F, k, (j + i1) + 0.5F, rotationYaw, rotationPitch); return; } } } } else { setPathToEntity(pathentity); } }
Example #8
Source File: MoCEntityAnimal.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
protected void getPathOrWalkableBlock(Entity entity, float f) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true); if ((pathentity == null) && (f > 8F)) { int i = MathHelper.floor_double(entity.posX) - 2; int j = MathHelper.floor_double(entity.posZ) - 2; int k = MathHelper.floor_double(entity.boundingBox.minY); for (int l = 0; l <= 4; l++) { for (int i1 = 0; i1 <= 4; i1++) { if (((l < 1) || (i1 < 1) || (l > 3) || (i1 > 3)) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1)) { setLocationAndAngles((i + l) + 0.5F, k, (j + i1) + 0.5F, rotationYaw, rotationPitch); return; } } } } else { setPathToEntity(pathentity); } }
Example #9
Source File: MoCEntityAnimal.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public void getMyOwnPath(Entity entity, float f) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true); if (pathentity != null) { setPathToEntity(pathentity); } }
Example #10
Source File: MoCEntityAnimal.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public void runLikeHell(Entity entity) { double d = posX - entity.posX; double d1 = posZ - entity.posZ; double d2 = Math.atan2(d, d1); d2 += (rand.nextFloat() - rand.nextFloat()) * 0.75D; double d3 = posX + (Math.sin(d2) * 8D); double d4 = posZ + (Math.cos(d2) * 8D); int i = MathHelper.floor_double(d3); int j = MathHelper.floor_double(boundingBox.minY); int k = MathHelper.floor_double(d4); int l = 0; do { if (l >= 16) { break; } int i1 = (i + rand.nextInt(4)) - rand.nextInt(4); int j1 = (j + rand.nextInt(3)) - rand.nextInt(3); int k1 = (k + rand.nextInt(4)) - rand.nextInt(4); if ((j1 > 4) && ((worldObj.getBlockId(i1, j1, k1) == 0) || (worldObj.getBlockId(i1, j1, k1) == Block.snow.blockID)) && (worldObj.getBlockId(i1, j1 - 1, k1) != 0)) { PathEntity pathentity = worldObj.getEntityPathToXYZ(this, i1, j1, k1, 16F, true, false, false, true); setPathToEntity(pathentity); break; } l++; } while (true); }
Example #11
Source File: MoCEntityAmbient.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public void runLikeHell(Entity entity) { double d = posX - entity.posX; double d1 = posZ - entity.posZ; double d2 = Math.atan2(d, d1); d2 += (rand.nextFloat() - rand.nextFloat()) * 0.75D; double d3 = posX + (Math.sin(d2) * 8D); double d4 = posZ + (Math.cos(d2) * 8D); int i = MathHelper.floor_double(d3); int j = MathHelper.floor_double(boundingBox.minY); int k = MathHelper.floor_double(d4); int l = 0; do { if (l >= 16) { break; } int i1 = (i + rand.nextInt(4)) - rand.nextInt(4); int j1 = (j + rand.nextInt(3)) - rand.nextInt(3); int k1 = (k + rand.nextInt(4)) - rand.nextInt(4); if ((j1 > 4) && ((worldObj.getBlockId(i1, j1, k1) == 0) || (worldObj.getBlockId(i1, j1, k1) == Block.snow.blockID)) && (worldObj.getBlockId(i1, j1 - 1, k1) != 0)) { PathEntity pathentity = worldObj.getEntityPathToXYZ(this, i1, j1, k1, 16F, true, false, false, true); setPathToEntity(pathentity); break; } l++; } while (true); }
Example #12
Source File: MoCEntityAmbient.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
private void followPlayer() { EntityPlayer entityplayer1 = worldObj.getClosestPlayerToEntity(this, 24D); if (entityplayer1 == null) { return; } ItemStack itemstack1 = entityplayer1.inventory.getCurrentItem(); if (itemstack1 != null && isMyFavoriteFood(itemstack1)) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entityplayer1, 16F, true, false, false, true); setPathToEntity(pathentity); } }
Example #13
Source File: MoCEntityAmbient.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
protected void getPathOrWalkableBlock(Entity entity, float f) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true); if ((pathentity == null) && (f > 8F)) { int i = MathHelper.floor_double(entity.posX) - 2; int j = MathHelper.floor_double(entity.posZ) - 2; int k = MathHelper.floor_double(entity.boundingBox.minY); for (int l = 0; l <= 4; l++) { for (int i1 = 0; i1 <= 4; i1++) { if (((l < 1) || (i1 < 1) || (l > 3) || (i1 > 3)) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1)) { setLocationAndAngles((i + l) + 0.5F, k, (j + i1) + 0.5F, rotationYaw, rotationPitch); return; } } } } else { setPathToEntity(pathentity); } }
Example #14
Source File: MoCEntityAmbient.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public void getMyOwnPath(Entity entity, float f) { PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true); if (pathentity != null) { setPathToEntity(pathentity); } }
Example #15
Source File: EntityAICustomDoorInteract.java From Et-Futurum with The Unlicense | 5 votes |
@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; } }
Example #16
Source File: MoCEntityInsect.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override public void onLivingUpdate() { super.onLivingUpdate(); /*if (!getIsFlying() && (motionY < 0.0D)) { motionY *= 0.6D; }*/ if (getIsFlying()) { moveSpeed = getFlyingSpeed(); } else { moveSpeed = getWalkingSpeed(); } if (MoCreatures.isServer()) { if (isOnLadder() && !onGround) { MoCServerPacketHandler.sendAnimationPacket(this.entityId, this.worldObj.provider.dimensionId, 1); } if (!getIsFlying() && rand.nextInt(getFlyingFreq()) == 0) { List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(4D, 4D, 4D)); for (int i = 0; i < list.size(); i++) { Entity entity1 = (Entity) list.get(i); if (!(entity1 instanceof EntityLiving)) { continue; } if (((EntityLiving) entity1).width >= 0.4F && ((EntityLiving) entity1).height >= 0.4F && canEntityBeSeen(entity1)) { this.motionY += 0.3D; setIsFlying(true); } } } if (isAttractedToLight() && rand.nextInt(50) == 0) { int ai[] = MoCTools.ReturnNearestBlockCoord(this, Block.torchWood.blockID, 8D); if (ai[0] > -1000) { PathEntity pathentity = worldObj.getEntityPathToXYZ(this,ai[0], ai[1], ai[2], 24F, true, false, false, true); if (pathentity != null) { this.setPathToEntity(pathentity); } } } //this makes the flying insect move all the time in the air if (getIsFlying() && !hasPath() && !isMovementCeased() && entityToAttack == null) { updateWanderPath(); } }else // client stuff { if (climbCounter > 0 && ++climbCounter > 8) { climbCounter = 0; } } }
Example #17
Source File: CoordTrackUpgradeHandler.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
public static PathEntity getDronePath(EntityPlayer player, int x, int y, int z){ World worldObj = player.worldObj; EntityDrone drone = new EntityDrone(worldObj); drone.setPosition(player.posX, player.posY - 2, player.posZ); return new EntityPathNavigateDrone(drone, worldObj).getEntityPathToXYZ(drone, x, y, z, SEARCH_RANGE, true, true, false, true); }
Example #18
Source File: EntityPathNavigateDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
/** * Returns the path to the given coordinates */ @Override public PathEntity getPathToXYZ(double par1, double par3, double par5){ return getEntityPathToXYZ(pathfindingEntity, MathHelper.floor_double(par1), (int)par3, MathHelper.floor_double(par5), getPathSearchRange(), false, false, true, false); }
Example #19
Source File: EntityPathNavigateDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
/** * Returns the path to the given EntityLiving */ @Override public PathEntity getPathToEntityLiving(Entity par1Entity){ return getPathEntityToEntity(pathfindingEntity, par1Entity, getPathSearchRange(), false, false, true, false); }
Example #20
Source File: EntityRabbit.java From Et-Futurum with The Unlicense | 4 votes |
@Override public void updateAITasks() { super.updateAITasks(); if (getMoveHelper().getSpeed() > 0.8D) setMoveType(EntityRabbit.EnumMoveType.SPRINT); else if (moveType != EntityRabbit.EnumMoveType.ATTACK) setMoveType(EntityRabbit.EnumMoveType.HOP); if (currentMoveTypeDuration > 0) currentMoveTypeDuration--; if (carrotTicks > 0) { carrotTicks -= rand.nextInt(3); if (carrotTicks < 0) carrotTicks = 0; } if (onGround) { if (!field_175537_bp) { setJumping(false, EntityRabbit.EnumMoveType.NONE); func_175517_cu(); } EntityRabbit.RabbitJumpHelper rabbitjumphelper = getJumpHelper(); if (!rabbitjumphelper.getIsJumping()) { if (!getNavigator().noPath() && currentMoveTypeDuration == 0) { PathEntity pathentity = getNavigator().getPath(); Vec3 vec3 = Vec3.createVectorHelper(getMoveHelper().getX(), getMoveHelper().getY(), getMoveHelper().getZ()); if (pathentity != null && pathentity.getCurrentPathIndex() < pathentity.getCurrentPathLength()) vec3 = pathentity.getPosition(this); calculateRotationYaw(vec3.xCoord, vec3.zCoord); doMovementAction(moveType); } } else if (!rabbitjumphelper.func_180065_d()) func_175518_cr(); } field_175537_bp = onGround; }