use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.
the class BlockQuarry method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (super.onBlockActivated(world, pos, state, entityplayer, facing, hitX, hitY, hitZ)) {
return true;
}
TileQuarry tile = (TileQuarry) world.getTileEntity(pos);
// Drop through if the player is sneaking
if (entityplayer.isSneaking()) {
return false;
}
// Restart the quarry if its a wrench
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pos)) {
tile.reinitalize();
((IToolWrench) equipped).wrenchUsed(entityplayer, pos);
return true;
}
return false;
}
use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.
the class BlockPump method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing face, float par7, float par8, float par9) {
if (super.onBlockActivated(world, pos, state, entityplayer, face, par7, par8, par9)) {
return true;
}
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TilePump) {
TilePump pump = (TilePump) tile;
// Drop through if the player is sneaking
if (entityplayer.isSneaking()) {
return false;
}
// Restart the pump if its a wrench
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pos)) {
pump.tank.reset();
pump.rebuildQueue();
((IToolWrench) equipped).wrenchUsed(entityplayer, pos);
return true;
}
}
return false;
}
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 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);
}
use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.
the class EntityUtil method activateWrench.
public static void activateWrench(EntityPlayer player) {
ItemStack stack = player.getHeldItemMainhand();
if (!stack.isEmpty() && stack.getItem() instanceof IToolWrench) {
IToolWrench wrench = (IToolWrench) stack.getItem();
wrench.wrenchUsed(player, EnumHand.MAIN_HAND, stack, null);
return;
}
stack = player.getHeldItemOffhand();
if (!stack.isEmpty() && stack.getItem() instanceof IToolWrench) {
IToolWrench wrench = (IToolWrench) stack.getItem();
wrench.wrenchUsed(player, EnumHand.OFF_HAND, stack, null);
}
}
use of buildcraft.api.tools.IToolWrench in project BuildCraft by BuildCraft.
the class EntityRobot method interact.
@Override
protected boolean interact(EntityPlayer player) {
ItemStack stack = player.getCurrentEquippedItem();
if (stack == null || stack.getItem() == null) {
return false;
}
RobotEvent.Interact robotInteractEvent = new RobotEvent.Interact(this, player, stack);
MinecraftForge.EVENT_BUS.post(robotInteractEvent);
if (robotInteractEvent.isCanceled()) {
return false;
}
if (player.isSneaking() && stack.getItem() instanceof IToolWrench) {
RobotEvent.Dismantle robotDismantleEvent = new RobotEvent.Dismantle(this, player);
MinecraftForge.EVENT_BUS.post(robotDismantleEvent);
if (robotDismantleEvent.isCanceled()) {
return false;
}
onRobotHit(false);
if (worldObj.isRemote) {
((IToolWrench) stack.getItem()).wrenchUsed(player, this);
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem().isValidArmor(stack, 0, this)) {
if (!worldObj.isRemote) {
wearables.add(stack.splitStack(1));
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof IRobotOverlayItem && ((IRobotOverlayItem) stack.getItem()).isValidRobotOverlay(stack)) {
if (!worldObj.isRemote) {
wearables.add(stack.splitStack(1));
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof ItemSkull) {
if (!worldObj.isRemote) {
ItemStack skullStack = stack.splitStack(1);
initSkullItem(skullStack);
wearables.add(skullStack);
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else {
return super.interact(player);
}
}
Aggregations