Search in sources :

Example 1 with TileForestry

use of forestry.core.gadgets.TileForestry in project ForestryMC by ForestryMC.

the class PacketHandler method onAccessSwitch.

private void onAccessSwitch(PacketCoordinates packet, EntityPlayer playerEntity) {
    assert FMLCommonHandler.instance().getEffectiveSide().isServer();
    TileForestry tile = (TileForestry) playerEntity.worldObj.getTileEntity(packet.posX, packet.posY, packet.posZ);
    if (tile == null) {
        return;
    }
    tile.switchAccessRule(playerEntity);
}
Also used : TileForestry(forestry.core.gadgets.TileForestry)

Example 2 with TileForestry

use of forestry.core.gadgets.TileForestry in project ForestryMC by ForestryMC.

the class TileGearbox method updateServerSide.

@Override
protected void updateServerSide() {
    super.updateServerSide();
    if (energyManager.getTotalEnergyStored() == 0) {
        ITileStructure central = getCentralTE();
        if (!(central instanceof TileForestry)) {
            return;
        }
        TileForestry centralHousing = (TileForestry) central;
        centralHousing.setErrorState(EnumErrorCode.NOPOWER);
        return;
    }
    if (activationDelay > 0) {
        activationDelay--;
        return;
    }
    // Hard limit to 4 cycles / second.
    if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) {
        workCounter++;
    }
    if (workCounter >= WORK_CYCLES && updateOnInterval(5)) {
        ITileStructure central = getCentralTE();
        if (!(central instanceof IFarmHousing)) {
            return;
        }
        if (((IFarmHousing) central).doWork()) {
            workCounter = 0;
            previousDelays = 0;
        } else {
            // If the central TE doesn't have work, we add to the activation delay to throttle the CPU usage.
            activationDelay = 10 * previousDelays < 120 ? 10 * previousDelays : 120;
            // First delay is free!
            previousDelays++;
        }
    }
}
Also used : ITileStructure(forestry.api.core.ITileStructure) IFarmHousing(forestry.api.farming.IFarmHousing) TileForestry(forestry.core.gadgets.TileForestry)

Aggregations

TileForestry (forestry.core.gadgets.TileForestry)2 ITileStructure (forestry.api.core.ITileStructure)1 IFarmHousing (forestry.api.farming.IFarmHousing)1