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);
}
}
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;
}
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();
}
}
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;
}
Aggregations