Search in sources :

Example 6 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.

the class BlockConstructionMarker method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing face, float hitX, float hitY, float hitZ) {
    if (super.onBlockActivated(world, pos, state, entityplayer, face, hitX, hitY, hitZ)) {
        return true;
    }
    TileConstructionMarker marker = (TileConstructionMarker) world.getTileEntity(pos);
    Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
    if (equipped instanceof ItemBlueprint) {
        if (marker.itemBlueprint == null) {
            ItemStack stack = entityplayer.inventory.getCurrentItem().copy();
            stack.stackSize = 1;
            marker.setBlueprint(stack);
            stack = null;
            if (entityplayer.inventory.getCurrentItem().stackSize > 1) {
                stack = entityplayer.getCurrentEquippedItem().copy();
                stack.stackSize = entityplayer.getCurrentEquippedItem().stackSize - 1;
            }
            entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, stack);
            return true;
        }
    } else if (equipped instanceof ItemConstructionMarker) {
        if (ItemConstructionMarker.linkStarted(entityplayer.getCurrentEquippedItem())) {
            ItemConstructionMarker.link(entityplayer.getCurrentEquippedItem(), world, pos);
            return true;
        }
    } else if ((equipped == null || equipped instanceof IToolWrench) && entityplayer.isSneaking()) {
        return dropMarkerIfPresent(world, pos, false);
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.

the class BlockRefinery method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (super.onBlockActivated(world, pos, state, player, side, hitX, hitY, hitZ)) {
        return true;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof TileRefinery)) {
        return false;
    }
    ItemStack current = player.getCurrentEquippedItem();
    Item equipped = current != null ? current.getItem() : null;
    if (player.isSneaking() && equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, pos)) {
        ((TileRefinery) tile).resetFilters();
        ((IToolWrench) equipped).wrenchUsed(player, pos);
        return true;
    }
    if (current != null) {
        if (!world.isRemote) {
            if (FluidContainerRegistry.isEmptyContainer(current)) {
                if (TankUtils.handleRightClick((TileRefinery) tile, side, player, false, true)) {
                    return true;
                }
            } else if (FluidContainerRegistry.isFilledContainer(current)) {
                if (TankUtils.handleRightClick((TileRefinery) tile, side, player, true, false)) {
                    return true;
                }
            }
        } else if (FluidContainerRegistry.isContainer(current)) {
            return true;
        }
    }
    if (!world.isRemote) {
        player.openGui(BuildCraftFactory.instance, GuiIds.REFINERY, world, pos.getX(), pos.getY(), pos.getZ());
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.

the class TileEngineCreative method onBlockActivated.

@Override
public boolean onBlockActivated(EntityPlayer player, EnumFacing side) {
    if (!getWorld().isRemote) {
        Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
        if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, pos)) {
            powerMode = powerMode.getNext();
            energy = 0;
            if (!(player instanceof FakePlayer)) {
                if (BuildCraftCore.hidePowerNumbers) {
                    player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless", LocaleUtil.localize("chat.pipe.power.iron.level." + powerMode.maxPower)));
                } else {
                    player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode", powerMode.maxPower));
                }
            }
            sendNetworkUpdate();
            ((IToolWrench) equipped).wrenchUsed(player, pos);
            return true;
        }
    }
    return !player.isSneaking();
}
Also used : Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 9 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.

the class BlockFloodGate method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float par7, float par8, float par9) {
    if (super.onBlockActivated(world, pos, state, entityplayer, side, par7, par8, par9)) {
        return true;
    }
    // Drop through if the player is sneaking
    if (entityplayer.isSneaking()) {
        return false;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileFloodGate) {
        TileFloodGate floodGate = (TileFloodGate) tile;
        // Restart the flood gate if it's a wrench
        Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
        if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pos)) {
            if (side == EnumFacing.UP) {
                floodGate.rebuildQueue();
            } else if (side != null) {
                floodGate.switchSide(side);
            }
            ((IToolWrench) equipped).wrenchUsed(entityplayer, pos);
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench)

Example 10 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.

the class TileEngineBase method onBlockActivated.

public boolean onBlockActivated(EntityPlayer player, EnumFacing side) {
    if (!player.worldObj.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
        IToolWrench wrench = (IToolWrench) player.getCurrentEquippedItem().getItem();
        if (wrench.canWrench(player, pos)) {
            if (getEnergyStage() == EnumEnergyStage.OVERHEAT && !Utils.isFakePlayer(player)) {
                energyStage = computeEnergyStage();
                sendNetworkUpdate();
            }
            checkOrientation = true;
            wrench.wrenchUsed(player, pos);
            return true;
        }
    }
    return false;
}
Also used : IToolWrench(buildcraft.api.tools.IToolWrench)

Aggregations

IToolWrench (buildcraft.api.tools.IToolWrench)15 Item (net.minecraft.item.Item)8 ItemStack (net.minecraft.item.ItemStack)7 TileEntity (net.minecraft.tileentity.TileEntity)4 RobotEvent (buildcraft.api.events.RobotEvent)1 IMapLocation (buildcraft.api.items.IMapLocation)1 IRobotOverlayItem (buildcraft.api.robots.IRobotOverlayItem)1 IPipePluggableItem (buildcraft.api.transport.pluggable.IPipePluggableItem)1 TileFloodGate (buildcraft.factory.tile.TileFloodGate)1 GatePluggable (buildcraft.transport.gates.GatePluggable)1 PipeEventItem (buildcraft.transport.pipes.events.PipeEventItem)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ItemSkull (net.minecraft.item.ItemSkull)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 EnumFacing (net.minecraft.util.EnumFacing)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1