use of pneumaticCraft.common.entity.EntityProgrammableController in project PneumaticCraft by MineMaarten.
the class TileEntityProgrammableController method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
oldCurX = curX;
oldCurY = curY;
oldCurZ = curZ;
if (PneumaticCraftUtils.distBetween(getPosition(), targetX, targetY, targetZ) <= getSpeed()) {
curX = targetX;
curY = targetY;
curZ = targetZ;
} else {
Vec3 vec = Vec3.createVectorHelper(targetX - curX, targetY - curY, targetZ - curZ).normalize();
curX += vec.xCoord * getSpeed();
curY += vec.yCoord * getSpeed();
curZ += vec.zCoord * getSpeed();
}
if (!worldObj.isRemote) {
getAIManager();
if (worldObj.getTotalWorldTime() % 40 == 0) {
dispenserUpgrades = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE);
speedUpgrades = getUpgrades(ItemMachineUpgrade.UPGRADE_SPEED_DAMAGE);
for (int i = getDroneSlots(); i < 36; i++) {
ItemStack stack = getFakePlayer().inventory.getStackInSlot(i);
if (stack != null) {
worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, stack));
getFakePlayer().inventory.setInventorySlotContents(i, null);
}
}
tank.setCapacity((dispenserUpgrades + 1) * 16000);
if (tank.getFluidAmount() > tank.getCapacity()) {
tank.getFluid().amount = tank.getCapacity();
}
}
for (int i = 0; i < 4; i++) {
getFakePlayer().theItemInWorldManager.updateBlockRemoving();
}
if (getPressure(ForgeDirection.UNKNOWN) >= getMinWorkingPressure()) {
if (!aiManager.isIdling())
addAir(-10, ForgeDirection.UNKNOWN);
aiManager.onUpdateTasks();
}
} else {
if (drone == null || drone.isDead) {
drone = new EntityProgrammableController(worldObj, this);
drone.posX = curX;
drone.posY = curY;
drone.posZ = curZ;
worldObj.spawnEntityInWorld(drone);
}
drone.setPosition(curX, curY, curZ);
// drone.getMoveHelper().setMoveTo(curX, curY, curZ, 0);
/* drone.prevPosX = oldCurX;
drone.prevPosY = oldCurY;
drone.prevPosZ = oldCurZ;*/
//drone.getMoveHelper().setMoveTo(curX, curY, curZ, getSpeed());
}
}
Aggregations