Search in sources :

Example 1 with EntityProgrammableController

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());
    }
}
Also used : EntityProgrammableController(pneumaticCraft.common.entity.EntityProgrammableController) Vec3(net.minecraft.util.Vec3) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3 (net.minecraft.util.Vec3)1 EntityProgrammableController (pneumaticCraft.common.entity.EntityProgrammableController)1