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