use of mcjty.lib.api.smartwrench.SmartWrenchSelector in project RFTools by McJty.
the class SmartWrenchItem method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
if (player.isSneaking()) {
// Make sure the block get activated if it is a GenericBlock
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof GenericBlock) {
if (DimensionalShardBlock.activateBlock(block, world, pos, state, player, hand, facing, hitX, hitY, hitZ)) {
return EnumActionResult.SUCCESS;
}
}
}
SmartWrenchMode mode = getCurrentMode(stack);
if (mode == SmartWrenchMode.MODE_SELECT) {
GlobalCoordinate b = getCurrentBlock(stack);
if (b != null) {
if (b.getDimension() != world.provider.getDimension()) {
Logging.message(player, TextFormatting.RED + "The selected block is in another dimension!");
return EnumActionResult.FAIL;
}
TileEntity te = world.getTileEntity(b.getCoordinate());
if (te instanceof SmartWrenchSelector) {
SmartWrenchSelector smartWrenchSelector = (SmartWrenchSelector) te;
smartWrenchSelector.selectBlock(player, pos);
}
}
}
}
return EnumActionResult.SUCCESS;
}
Aggregations