boolean ret = false; RightClickBlock e = new RightClickBlock(player, hand, pos, side, new Vec3d(hitX, hitY, hitZ)); if (MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.getUseBlock() == Result.DENY || e.getUseItem() == Result.DENY) { return EnumActionResult.PASS;
@SubscribeEvent public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) if (event.isCanceled() || event.getResult() != Event.Result.DEFAULT) return;
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY || event.getUseItem() == Result.DENY || event.getUseBlock() == Result.DENY) { return EnumActionResult.PASS;
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY || event.getUseBlock() == Result.DENY || event.getUseItem() == Result.DENY) { return EnumActionResult.PASS;
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (world.isAirBlock(pos)) { return EnumActionResult.PASS; } PlayerInteractEvent.RightClickBlock event = new PlayerInteractEvent.RightClickBlock(player, hand, pos, side, new Vec3d(hitX, hitY, hitZ)); if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY || event.getUseBlock() == Result.DENY || event.getUseItem() == Result.DENY) { return EnumActionResult.PASS; } if (ServerHelper.isServerWorld(world) && player.isSneaking() && block instanceof IDismantleable && ((IDismantleable) block).canDismantle(world, pos, state, player)) { ((IDismantleable) block).dismantleBlock(world, pos, state, player, false); return EnumActionResult.SUCCESS; } if (BlockHelper.canRotate(block)) { world.setBlockState(pos, BlockHelper.rotateVanillaBlock(world, state, pos), 3); player.swingArm(hand); return ServerHelper.isServerWorld(world) ? EnumActionResult.SUCCESS : EnumActionResult.PASS; } else if (!player.isSneaking() && block.rotateBlock(world, pos, side)) { player.swingArm(hand); return ServerHelper.isServerWorld(world) ? EnumActionResult.SUCCESS : EnumActionResult.PASS; } return EnumActionResult.PASS; }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { if(event.getEntityPlayer().isSneaking() || event.isCanceled() || event.getResult() == Result.DENY) return; World world = event.getWorld(); IBlockState state = world.getBlockState(event.getPos()).getActualState(world, event.getPos()); Block block = state.getBlock(); if(!(block instanceof BlockDoor)) return; EnumFacing direction = state.getValue(BlockDoor.FACING); boolean isOpen = state.getValue(BlockDoor.OPEN); BlockDoor.EnumHingePosition isMirrored = state.getValue(BlockDoor.HINGE); BlockPos mirrorPos = event.getPos().offset(isMirrored == BlockDoor.EnumHingePosition.RIGHT ? direction.rotateYCCW() : direction.rotateY()); BlockPos doorPos = state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER ? mirrorPos : mirrorPos.down(); IBlockState other = world.getBlockState(doorPos).getActualState(world, doorPos); if(block.getMaterial(state) != Material.IRON && other.getBlock() == (BlockDoor) block && other.getValue(BlockDoor.FACING) == direction && other.getValue(BlockDoor.OPEN) == isOpen && other.getValue(BlockDoor.HINGE) != isMirrored) { IBlockState newState = other.cycleProperty(BlockDoor.OPEN); world.setBlockState(doorPos, newState, 10); } }