public boolean isBlockTracked(Class<? extends Block> block, int meta) { for (SegmentBlock segment : segmentsBlocks) { if (segment.getCheckClass().isAssignableFrom(block) && (segment.getMeta() == -1 || segment.getMeta() == meta)) return true; } return false; }
/** Checking right click actions on blocks. */ public boolean checkBlockInteraction( Resident res, BlockPos bp, PlayerInteractEvent.Action action) { Block blockType = DimensionManager.getWorld(bp.getDim()).getBlock(bp.getX(), bp.getY(), bp.getZ()); for (SegmentBlock segment : segmentsBlocks) { if (segment.getCheckClass().isAssignableFrom(blockType.getClass()) && (segment.getMeta() == -1 || segment.getMeta() == DimensionManager.getWorld(bp.getDim()) .getBlockMetadata(bp.getX(), bp.getY(), bp.getZ())) && (segment.getType() == BlockType.ANY_CLICK || segment.getType() == BlockType.RIGHT_CLICK && action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || segment.getType() == BlockType.LEFT_CLICK && action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) { int dim = bp.getDim(); int x = bp.getX(); int y = bp.getY(); int z = bp.getZ(); if (!hasPermission(res, segment, dim, x, y, z)) { if (segment.hasClientUpdate()) sendClientUpdate( segment.getClientUpdateCoords(), bp, (EntityPlayerMP) res.getPlayer(), null); return true; } } } return false; }
public static void checkBlockInteraction( Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) { if (!ev.isCancelable()) { return; } World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim()); Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ()); for (SegmentBlock segment : segmentsBlock.get(block.getClass())) { if (!segment.shouldInteract(res, bp, action)) { ev.setCanceled(true); } } }