use of gregtech.api.capability.tool.IScrewdriverItem in project GregTech by GregTechCE.
the class BlockPipe method onPipeActivated.
public boolean onPipeActivated(EntityPlayer entityPlayer, EnumHand hand, CuboidRayTraceResult hit, IPipeTile<PipeType, NodeDataType> pipeTile) {
ItemStack itemStack = entityPlayer.getHeldItem(hand);
EnumFacing coverSide = ICoverable.traceCoverSide(hit);
if (coverSide == null)
return false;
if (!(hit.cuboid6.data instanceof CoverSideData)) {
IWrenchItem wrenchItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_WRENCH, null);
if (wrenchItem != null) {
if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true)) {
if (!entityPlayer.world.isRemote) {
boolean isBlocked = pipeTile.isConnectionBlocked(AttachmentType.PIPE, coverSide);
pipeTile.setConnectionBlocked(AttachmentType.PIPE, coverSide, !isBlocked);
wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, false);
}
return true;
}
return false;
}
}
CoverBehavior coverBehavior = pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
if (coverBehavior == null)
return false;
IScrewdriverItem screwdriver = itemStack.getCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null);
if (screwdriver != null) {
if (screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, true) && coverBehavior.onScrewdriverClick(entityPlayer, hand, hit) == EnumActionResult.SUCCESS) {
screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false);
return true;
}
return false;
}
return coverBehavior.onRightClick(entityPlayer, hand, hit) == EnumActionResult.SUCCESS;
}
use of gregtech.api.capability.tool.IScrewdriverItem in project GregTech by GregTechCE.
the class BlockMachine method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
ItemStack itemStack = playerIn.getHeldItem(hand);
if (metaTileEntity == null || rayTraceResult == null) {
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null)) {
IScrewdriverItem screwdriver = itemStack.getCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null);
if (screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, true) && metaTileEntity.onCoverScrewdriverClick(playerIn, hand, rayTraceResult)) {
screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false);
return true;
}
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_WRENCH, null)) {
IWrenchItem wrenchItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_WRENCH, null);
EnumFacing wrenchDirection = ICoverable.determineGridSideHit(rayTraceResult);
if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true) && metaTileEntity.onWrenchClick(playerIn, hand, wrenchDirection, rayTraceResult)) {
wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, false);
return true;
}
return false;
}
return metaTileEntity.onCoverRightClick(playerIn, hand, rayTraceResult);
}
Aggregations