Search in sources :

Example 1 with IAlvearyComponent

use of forestry.api.apiculture.IAlvearyComponent in project ForestryMC by ForestryMC.

the class TileAlvearyHygroregulator method updateServerSide.

@Override
protected void updateServerSide() {
    super.updateServerSide();
    if (transferTime <= 0 && liquidTank.getFluidAmount() > 0) {
        currentRecipe = getRecipe(liquidTank.getFluid());
        if (currentRecipe != null) {
            liquidTank.drain(currentRecipe.liquid.amount, true);
            transferTime = currentRecipe.transferTime;
        }
    }
    if (transferTime > 0) {
        transferTime--;
        if (currentRecipe != null) {
            IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
            if (component != null) {
                component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f);
                component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f);
            }
        } else {
            transferTime = 0;
        }
    }
    if (!updateOnInterval(20)) {
        return;
    }
    IInventoryAdapter canInventory = getInternalInventory();
    // Check if we have suitable items waiting in the item slot
    if (canInventory.getStackInSlot(0) != null) {
        FluidHelper.drainContainers(tankManager, canInventory, 0);
    }
}
Also used : IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) IAlvearyComponent(forestry.api.apiculture.IAlvearyComponent)

Example 2 with IAlvearyComponent

use of forestry.api.apiculture.IAlvearyComponent in project ForestryMC by ForestryMC.

the class StructureLogicAlveary method determineMasterState.

@Override
protected EnumStructureState determineMasterState(Schemata schemata, boolean rotate) {
    Vect dimensions = schemata.getDimensions(rotate);
    int offsetX = schemata.getxOffset();
    int offsetZ = schemata.getzOffset();
    if (rotate) {
        offsetX = schemata.getzOffset();
        offsetZ = schemata.getxOffset();
    }
    for (int i = 0; i < dimensions.x; i++) {
        for (int j = 0; j < schemata.getHeight(); j++) {
            for (int k = 0; k < dimensions.z; k++) {
                int x = structureTile.xCoord + i + offsetX;
                int y = structureTile.yCoord + j + schemata.getyOffset();
                int z = structureTile.zCoord + k + offsetZ;
                if (!structureTile.getWorldObj().blockExists(x, y, z)) {
                    return EnumStructureState.INDETERMINATE;
                }
                EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
                if (required == EnumStructureBlock.ANY) {
                    continue;
                }
                TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
                Block block = structureTile.getWorldObj().getBlock(x, y, z);
                switch(required) {
                    case AIR:
                        if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    case BLOCK_A:
                        if (tile == null || !(tile instanceof IAlvearyComponent)) {
                            return EnumStructureState.INVALID;
                        }
                        if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    case MASTER:
                    case BLOCK_B:
                        if (tile == null || !(tile instanceof TileAlvearyPlain)) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    case BLOCK_C:
                        if (!slabBlocks.contains(block)) {
                            return EnumStructureState.INVALID;
                        }
                        if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    case BLOCK_D:
                        if (block != Blocks.spruce_stairs) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    case FOREIGN:
                        if (tile instanceof ITileStructure) {
                            return EnumStructureState.INVALID;
                        }
                        break;
                    default:
                        return EnumStructureState.INDETERMINATE;
                }
            }
        }
    }
    return EnumStructureState.VALID;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITileStructure(forestry.api.core.ITileStructure) Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block) ForestryBlock(forestry.core.config.ForestryBlock) EnumStructureBlock(forestry.core.utils.Schemata.EnumStructureBlock) IAlvearyComponent(forestry.api.apiculture.IAlvearyComponent) EnumStructureBlock(forestry.core.utils.Schemata.EnumStructureBlock)

Example 3 with IAlvearyComponent

use of forestry.api.apiculture.IAlvearyComponent in project ForestryMC by ForestryMC.

the class TileAlvearyClimatiser method updateServerSide.

/* UPDATING */
@Override
protected void updateServerSide() {
    super.updateServerSide();
    if (!this.hasMaster()) {
        return;
    }
    boolean wasInactive = (workingTime == 0);
    if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
        // consume 10 RF per tick of work
        workingTime += energyManager.getEnergyPerWork() / 10;
    }
    if (workingTime > 0) {
        workingTime--;
        IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
        if (component != null) {
            component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
        }
    }
    if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
        sendNetworkUpdate();
    }
}
Also used : IAlvearyComponent(forestry.api.apiculture.IAlvearyComponent)

Example 4 with IAlvearyComponent

use of forestry.api.apiculture.IAlvearyComponent in project ForestryMC by ForestryMC.

the class TileAlvearySwarmer method getPrincessStack.

private ItemStack getPrincessStack() {
    if (!this.hasMaster()) {
        return null;
    }
    IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
    if (!(master instanceof IBeeHousing)) {
        return null;
    }
    IBeeHousing housing = (IBeeHousing) master;
    ItemStack princessStack = housing.getQueen();
    if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) {
        return null;
    }
    return princessStack;
}
Also used : IBeeHousing(forestry.api.apiculture.IBeeHousing) ItemStack(net.minecraft.item.ItemStack) IAlvearyComponent(forestry.api.apiculture.IAlvearyComponent)

Aggregations

IAlvearyComponent (forestry.api.apiculture.IAlvearyComponent)4 IBeeHousing (forestry.api.apiculture.IBeeHousing)1 ITileStructure (forestry.api.core.ITileStructure)1 ForestryBlock (forestry.core.config.ForestryBlock)1 IInventoryAdapter (forestry.core.inventory.IInventoryAdapter)1 EnumStructureBlock (forestry.core.utils.Schemata.EnumStructureBlock)1 Vect (forestry.core.vect.Vect)1 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1