Search in sources :

Example 1 with MultiblockValidationException

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"));
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) MultiblockValidationException(forestry.core.multiblock.MultiblockValidationException)

Example 2 with MultiblockValidationException

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"));
    }
}
Also used : TileFarmGearbox(forestry.farming.tiles.TileFarmGearbox) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent) MultiblockValidationException(forestry.core.multiblock.MultiblockValidationException)

Example 3 with MultiblockValidationException

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"));
    }
}
Also used : TileGreenhousePlain(forestry.greenhouse.tiles.TileGreenhousePlain) MultiblockValidationException(forestry.core.multiblock.MultiblockValidationException) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock)

Aggregations

MultiblockValidationException (forestry.core.multiblock.MultiblockValidationException)3 IMultiblockComponent (forestry.api.multiblock.IMultiblockComponent)1 TileFarmGearbox (forestry.farming.tiles.TileFarmGearbox)1 IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)1 TileGreenhousePlain (forestry.greenhouse.tiles.TileGreenhousePlain)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1