use of forestry.core.multiblock.MultiblockValidationException in project ForestryMC by ForestryMC.
the class AlvearyController method isMachineWhole.
@Override
protected void isMachineWhole() throws MultiblockValidationException {
super.isMachineWhole();
final BlockPos maximumCoord = getMaximumCoord();
final BlockPos minimumCoord = getMinimumCoord();
// check that the top is covered in wood slabs
final int slabY = maximumCoord.getY() + 1;
for (int slabX = minimumCoord.getX(); slabX <= maximumCoord.getX(); slabX++) {
for (int slabZ = minimumCoord.getZ(); slabZ <= maximumCoord.getZ(); slabZ++) {
BlockPos pos = new BlockPos(slabX, slabY, slabZ);
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (!BlockUtil.isWoodSlabBlock(state, block, world, pos)) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSlabs"));
}
int meta = block.getMetaFromState(state);
if ((meta & 8) != 0) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSlabs"));
}
}
}
// check that there is space all around the alveary entrances
int airY = maximumCoord.getY();
for (int airX = minimumCoord.getX() - 1; airX <= maximumCoord.getX() + 1; airX++) {
for (int airZ = minimumCoord.getZ() - 1; airZ <= maximumCoord.getZ() + 1; airZ++) {
if (isCoordInMultiblock(airX, airY, airZ)) {
continue;
}
IBlockState blockState = world.getBlockState(new BlockPos(airX, airY, airZ));
if (blockState.isOpaqueCube()) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSpace"));
}
}
}
}
use of forestry.core.multiblock.MultiblockValidationException in project ForestryMC by ForestryMC.
the class FarmController method isMachineWhole.
@Override
protected void isMachineWhole() throws MultiblockValidationException {
super.isMachineWhole();
boolean hasGearbox = false;
for (IMultiblockComponent part : connectedParts) {
if (part instanceof TileFarmGearbox) {
hasGearbox = true;
break;
}
}
if (!hasGearbox) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.farm.error.needGearbox"));
}
}
use of forestry.core.multiblock.MultiblockValidationException in project ForestryMC by ForestryMC.
the class GreenhouseController method isGoodForExteriorLevel.
/* RectangularMultiblockControllerBase */
@Override
public void isGoodForExteriorLevel(IMultiblockComponent part, int level) throws MultiblockValidationException {
int maxLevel = getMaximumCoord().getY() - getMinimumCoord().getY();
if (level == maxLevel && !(part instanceof TileGreenhousePlain)) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.needPlainOnTop"));
}
IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(world, part.getCoordinates());
if (logicBlock != null && logicBlock.getProvider() != getProvider()) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.needSpace"));
}
}
Aggregations