Search in sources :

Example 1 with TileFloodGate

use of buildcraft.factory.tile.TileFloodGate in project BuildCraft by BuildCraft.

the class BlockFloodGate method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = player.getHeldItem(hand);
    if (heldItem.getItem() instanceof IToolWrench) {
        if (!world.isRemote) {
            if (side != EnumFacing.UP) {
                TileEntity tile = world.getTileEntity(pos);
                if (tile instanceof TileFloodGate) {
                    if (CONNECTED_MAP.containsKey(side)) {
                        TileFloodGate floodGate = (TileFloodGate) tile;
                        if (!floodGate.openSides.remove(side)) {
                            floodGate.openSides.add(side);
                        }
                        floodGate.queue.clear();
                        floodGate.sendNetworkUpdate(TileBC_Neptune.NET_RENDER_DATA);
                        return true;
                    }
                }
            }
        }
        return false;
    }
    return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IToolWrench(buildcraft.api.tools.IToolWrench) ItemStack(net.minecraft.item.ItemStack) TileFloodGate(buildcraft.factory.tile.TileFloodGate)

Aggregations

IToolWrench (buildcraft.api.tools.IToolWrench)1 TileFloodGate (buildcraft.factory.tile.TileFloodGate)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1