use of gregtech.api.cover.ICoverable.CoverSideData 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.cover.ICoverable.CoverSideData in project GregTech by GregTechCE.
the class BlockPipe method getPickBlock.
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(world, pos);
if (pipeTile == null) {
return ItemStack.EMPTY;
}
if (target instanceof CuboidRayTraceResult) {
CuboidRayTraceResult result = (CuboidRayTraceResult) target;
if (result.cuboid6.data instanceof CoverSideData) {
EnumFacing coverSide = ((CoverSideData) result.cuboid6.data).side;
CoverBehavior coverBehavior = pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
return coverBehavior == null ? ItemStack.EMPTY : coverBehavior.getPickItem();
}
}
return getDropItem(pipeTile);
}
Aggregations