Search in sources :

Example 1 with TileEntityChannel

use of com.infinityraider.agricraft.tiles.irrigation.TileEntityChannel in project AgriCraft by AgriCraft.

the class BlockWaterChannel method getBoundingBox.

@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
    // Fetch Tile Entity
    final Optional<TileEntityChannel> tile = WorldHelper.getTile(world, pos, TileEntityChannel.class);
    // Define Core Bounding Box
    AxisAlignedBB selection = CENTER_BOX;
    // Expand Bounding Box
    if (tile.isPresent()) {
        if (tile.get().hasNeighbor(EnumFacing.NORTH)) {
            selection = selection.union(NORTH_BOX);
        }
        if (tile.get().hasNeighbor(EnumFacing.EAST)) {
            selection = selection.union(EAST_BOX);
        }
        if (tile.get().hasNeighbor(EnumFacing.SOUTH)) {
            selection = selection.union(SOUTH_BOX);
        }
        if (tile.get().hasNeighbor(EnumFacing.WEST)) {
            selection = selection.union(WEST_BOX);
        }
    }
    return selection;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntityChannel(com.infinityraider.agricraft.tiles.irrigation.TileEntityChannel)

Example 2 with TileEntityChannel

use of com.infinityraider.agricraft.tiles.irrigation.TileEntityChannel in project AgriCraft by AgriCraft.

the class AbstractBlockWaterChannel method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    final Optional<TileEntityChannel> tile = WorldHelper.getTile(world, pos, TileEntityChannel.class);
    if (!tile.isPresent()) {
        return state;
    }
    tile.get().checkConnections();
    final IrrigationConnection sides = new IrrigationConnection();
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        sides.set(facing, tile.get().getConnectionType(facing));
    }
    return sides.write(state);
}
Also used : IrrigationConnection(com.infinityraider.agricraft.api.v1.irrigation.IrrigationConnection) EnumFacing(net.minecraft.util.EnumFacing) TileEntityChannel(com.infinityraider.agricraft.tiles.irrigation.TileEntityChannel)

Aggregations

TileEntityChannel (com.infinityraider.agricraft.tiles.irrigation.TileEntityChannel)2 IrrigationConnection (com.infinityraider.agricraft.api.v1.irrigation.IrrigationConnection)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1