use of net.minecraft.pathfinding.PathPoint in project PneumaticCraft by MineMaarten.
the class EntityDrone method onUpdate.
@Override
public void onUpdate() {
if (firstTick) {
firstTick = false;
volume = PneumaticValues.DRONE_VOLUME + getUpgrades(ItemMachineUpgrade.UPGRADE_VOLUME_DAMAGE) * PneumaticValues.VOLUME_VOLUME_UPGRADE;
hasLiquidImmunity = getUpgrades(ItemMachineUpgrade.UPGRADE_SECURITY) > 0;
if (hasLiquidImmunity) {
((EntityPathNavigateDrone) getPathNavigator()).pathThroughLiquid = true;
}
speed = 0.1 + Math.min(10, getUpgrades(ItemMachineUpgrade.UPGRADE_SPEED_DAMAGE)) * 0.01;
lifeUpgrades = getUpgrades(ItemMachineUpgrade.UPGRADE_ITEM_LIFE);
if (!worldObj.isRemote)
setHasMinigun(getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER) > 0);
aiManager.setWidgets(progWidgets);
}
boolean enabled = !disabledByHacking && getPressure(null) > 0.01F;
if (!worldObj.isRemote) {
setAccelerating(!standby && enabled);
if (isAccelerating()) {
fallDistance = 0;
}
if (lifeUpgrades > 0) {
int interval = 10 / lifeUpgrades;
if (interval == 0 || ticksExisted % interval == 0) {
heal(1);
}
}
if (!isSuffocating) {
suffocationCounter = 40;
}
isSuffocating = false;
PathEntity path = getNavigator().getPath();
if (path != null) {
PathPoint target = path.getFinalPathPoint();
if (target != null) {
setTargetedBlock(target.xCoord, target.yCoord, target.zCoord);
} else {
setTargetedBlock(0, 0, 0);
}
} else {
setTargetedBlock(0, 0, 0);
}
if (worldObj.getTotalWorldTime() % 20 == 0) {
updateSyncedPlayers();
}
} else {
if (digLaser != null)
digLaser.update();
oldLaserExtension = laserExtension;
if (getActiveProgramKey().equals("dig")) {
laserExtension = Math.min(1, laserExtension + LASER_EXTEND_SPEED);
} else {
laserExtension = Math.max(0, laserExtension - LASER_EXTEND_SPEED);
}
if (isAccelerating()) {
int x = (int) Math.floor(posX);
int y = (int) Math.floor(posY - 1);
int z = (int) Math.floor(posZ);
Block block = null;
for (int i = 0; i < 3; i++) {
block = worldObj.getBlock(x, y, z);
if (block.getMaterial() != Material.air)
break;
y--;
}
if (block.getMaterial() != Material.air) {
Vec3 vec = Vec3.createVectorHelper(posY - y, 0, 0);
vec.rotateAroundY((float) (rand.nextFloat() * Math.PI * 2));
worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + worldObj.getBlockMetadata(x, y, z), posX + vec.xCoord, y + 1, posZ + vec.zCoord, vec.xCoord, 0, vec.zCoord);
}
}
}
if (hasLiquidImmunity) {
for (int x = (int) posX - 1; x <= (int) (posX + width); x++) {
for (int y = (int) posY - 1; y <= (int) (posY + height + 1); y++) {
for (int z = (int) posZ - 2; z <= (int) (posZ + width); z++) {
if (PneumaticCraftUtils.isBlockLiquid(worldObj.getBlock(x, y, z))) {
worldObj.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
}
if (isAccelerating()) {
motionX *= 0.3D;
motionY *= 0.3D;
motionZ *= 0.3D;
propSpeed = Math.min(1, propSpeed + 0.04F);
addAir(null, -1);
} else {
propSpeed = Math.max(0, propSpeed - 0.04F);
}
oldPropRotation = propRotation;
propRotation += propSpeed;
if (!worldObj.isRemote && isEntityAlive()) /*((FakePlayerItemInWorldManager)fakePlayer.theItemInWorldManager).isDigging()*/
{
for (int i = 0; i < 4; i++) {
getFakePlayer().theItemInWorldManager.updateBlockRemoving();
}
}
super.onUpdate();
if (hasMinigun())
getMinigun().setAttackTarget(getAttackTarget()).update(posX, posY, posZ);
if (!worldObj.isRemote && isEntityAlive()) {
if (enabled)
aiManager.onUpdateTasks();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (getEmittingRedstone(d) > 0) {
if (worldObj.isAirBlock((int) Math.floor(posX + width / 2), (int) Math.floor(posY), (int) Math.floor(posZ + width / 2))) {
worldObj.setBlock((int) Math.floor(posX + width / 2), (int) Math.floor(posY), (int) Math.floor(posZ + width / 2), Blockss.droneRedstoneEmitter);
}
break;
}
}
}
}
use of net.minecraft.pathfinding.PathPoint in project Galacticraft by micdoodle8.
the class WalkNodeProcessorCeiling method getStart.
@Override
public PathPoint getStart() {
int i;
if (this.getCanSwim() && this.entity.isInWater()) {
i = (int) this.entity.getEntityBoundingBox().minY;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock()) {
++i;
blockpos$mutableblockpos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
}
} else if (this.entity.onGround) {
i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
} else {
BlockPos blockpos;
for (blockpos = new BlockPos(this.entity); (this.blockaccess.getBlockState(blockpos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(blockpos).getBlock().isPassable(this.blockaccess, blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down()) {
;
}
i = blockpos.up().getY();
}
BlockPos blockpos2 = new BlockPos(this.entity);
PathNodeType pathnodetype1 = this.getPathNodeType(this.entity, blockpos2.getX(), i, blockpos2.getZ());
if (this.entity.getPathPriority(pathnodetype1) < 0.0F) {
Set<BlockPos> set = Sets.<BlockPos>newHashSet();
set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double) i, this.entity.getEntityBoundingBox().minZ));
set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double) i, this.entity.getEntityBoundingBox().maxZ));
set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, (double) i, this.entity.getEntityBoundingBox().minZ));
set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, (double) i, this.entity.getEntityBoundingBox().maxZ));
for (BlockPos blockpos1 : set) {
PathNodeType pathnodetype = this.getPathNodeType(this.entity, blockpos1);
if (this.entity.getPathPriority(pathnodetype) >= 0.0F) {
return this.openPoint(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
}
}
}
return this.openPoint(blockpos2.getX(), i, blockpos2.getZ());
}
Aggregations