@SubscribeEvent public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) if (event.isCanceled() || event.getResult() != Event.Result.DEFAULT) return;
if (event.isCanceled()) 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); } }