Search in sources :

Example 11 with IToolWrench

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

the class PipeItemsDaizuli method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumFacing side) {
    if (player.isSneaking()) {
        Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
        if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, container.getPos())) {
            setColor(ColorUtils.next(getColor()));
            ((IToolWrench) equipped).wrenchUsed(player, container.getPos());
            return true;
        }
    }
    EnumDyeColor color = ColorUtils.getColorFromDye(player.getCurrentEquippedItem());
    if (color != null) {
        setColor(color);
        return true;
    }
    return logic.blockActivated(player, EnumPipePart.fromFacing(side));
}
Also used : Item(net.minecraft.item.Item) PipeEventItem(buildcraft.transport.pipes.events.PipeEventItem) IToolWrench(buildcraft.api.tools.IToolWrench) EnumDyeColor(net.minecraft.item.EnumDyeColor)

Example 12 with IToolWrench

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

the class PipeLogicIron method blockActivated.

public boolean blockActivated(EntityPlayer entityplayer, EnumPipePart side) {
    Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
    if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.getPos())) {
        if (side == EnumPipePart.CENTER || !pipe.getContainer().isPipeConnected(side.face)) {
            switchPosition();
        } else {
            setFacing(side.face);
        }
        pipe.container.scheduleRenderUpdate();
        ((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.getPos());
        return true;
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench)

Example 13 with IToolWrench

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

the class BlockGenericPipe method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float xOffset, float yOffset, float zOffset) {
    if (super.onBlockActivated(world, pos, state, player, side, xOffset, yOffset, zOffset)) {
        return true;
    }
    world.notifyBlockOfStateChange(pos, BuildCraftTransport.genericPipeBlock);
    Pipe<?> pipe = getPipe(world, pos);
    RaytraceResult rayTrace = doRayTrace(world, pos, player);
    if (rayTrace != null) {
        side = rayTrace.sideHit;
    }
    if (isValid(pipe)) {
        ItemStack currentItem = player.getCurrentEquippedItem();
        // from the pipe.
        if (player.isSneaking() && currentItem == null) {
            if (stripEquipment(world, pos, player, pipe, side)) {
                return true;
            }
        } else if (currentItem == null) {
        // Fall through the end of the test
        } else if (currentItem.getItem() == Items.sign) {
            // Sign will be placed anyway, so lets show the sign gui
            return false;
        } else if (currentItem.getItem() instanceof ItemPipe) {
            return false;
        } else if (currentItem.getItem() instanceof ItemGateCopier) {
            return false;
        } else if (currentItem.getItem() instanceof IToolWrench) {
            // Only check the instance at this point. Call the IToolWrench
            // interface callbacks for the individual pipe/logic calls
            RaytraceResult rayTraceResult = doRayTrace(world, pos, player);
            if (rayTraceResult != null) {
                EnumFacing hitSide = rayTraceResult.hitPart == Part.Pipe ? rayTraceResult.sideHit : null;
                return pipe.blockActivated(player, hitSide);
            } else {
                return pipe.blockActivated(player, null);
            }
        } else if (currentItem.getItem() instanceof IMapLocation) {
            // We want to be able to record pipe locations
            return false;
        } else if (PipeWire.RED.isPipeWire(currentItem)) {
            if (addOrStripWire(player, pipe, PipeWire.RED)) {
                return true;
            }
        } else if (PipeWire.BLUE.isPipeWire(currentItem)) {
            if (addOrStripWire(player, pipe, PipeWire.BLUE)) {
                return true;
            }
        } else if (PipeWire.GREEN.isPipeWire(currentItem)) {
            if (addOrStripWire(player, pipe, PipeWire.GREEN)) {
                return true;
            }
        } else if (PipeWire.YELLOW.isPipeWire(currentItem)) {
            if (addOrStripWire(player, pipe, PipeWire.YELLOW)) {
                return true;
            }
        } else if (currentItem.getItem() == Items.water_bucket) {
            if (!world.isRemote) {
                pipe.container.setPipeColor(-1);
            }
            return true;
        } else if (currentItem.getItem() instanceof IPipePluggableItem) {
            if (addOrStripPipePluggable(world, pos, currentItem, player, side, pipe)) {
                return true;
            }
        }
        Gate clickedGate = null;
        if (rayTrace != null && rayTrace.hitPart == Part.Pluggable && pipe.container.getPipePluggable(rayTrace.sideHit) instanceof GatePluggable) {
            clickedGate = pipe.gates[rayTrace.sideHit.ordinal()];
        }
        if (clickedGate != null) {
            clickedGate.openGui(player);
            return true;
        } else {
            if (pipe.blockActivated(player, side)) {
                return true;
            }
            if (rayTrace != null) {
                EnumFacing hitSide = rayTrace.hitPart == Part.Pipe ? rayTrace.sideHit : null;
                return pipe.blockActivated(player, hitSide);
            }
        }
    }
    return false;
}
Also used : IToolWrench(buildcraft.api.tools.IToolWrench) EnumFacing(net.minecraft.util.EnumFacing) IMapLocation(buildcraft.api.items.IMapLocation) ItemStack(net.minecraft.item.ItemStack) IPipePluggableItem(buildcraft.api.transport.pluggable.IPipePluggableItem) GatePluggable(buildcraft.transport.gates.GatePluggable)

Example 14 with IToolWrench

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

the class EntityUtil method getWrenchHand.

public static EnumHand getWrenchHand(EntityLivingBase entity) {
    ItemStack stack = entity.getHeldItemMainhand();
    if (!stack.isEmpty() && stack.getItem() instanceof IToolWrench) {
        return EnumHand.MAIN_HAND;
    }
    stack = entity.getHeldItemOffhand();
    if (!stack.isEmpty() && stack.getItem() instanceof IToolWrench) {
        return EnumHand.OFF_HAND;
    }
    return null;
}
Also used : IToolWrench(buildcraft.api.tools.IToolWrench) ItemStack(net.minecraft.item.ItemStack)

Example 15 with IToolWrench

use of buildcraft.api.tools.IToolWrench in project RFTools by McJty.

the class BuildCraftChecker method useBuildcraftWrench.

public static void useBuildcraftWrench(Item item, EntityPlayer player, BlockPos pos) {
    IToolWrench wrench = (IToolWrench) item;
    wrench.wrenchUsed(player, pos);
}
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