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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations