Java Code Examples for org.bukkit.block.Block#getZ()
The following examples show how to use
org.bukkit.block.Block#getZ() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupSign.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
/** * @param plugin the plugin instance * @param block a block which is protected by the returned GroupSign * @return the group sign the block belongs to, null if it belongs to none */ public static GroupSign getByBlock(DungeonsXL plugin, Block block) { if (!Category.SIGNS.containsBlock(block)) { return null; } for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(GroupSign.class)) { GroupSign groupSign = (GroupSign) protection; Block start = groupSign.startSign; if (start == block || (start.getX() == block.getX() && start.getZ() == block.getZ() && (start.getY() >= block.getY() && start.getY() - groupSign.verticalSigns <= block.getY()))) { return groupSign; } } return null; }
Example 2
Source File: HillObjective.java From CardinalPGM with MIT License | 6 votes |
private void renderBlocks() { if (progress == null) return; byte color1 = capturingTeam != null ? MiscUtil.convertChatColorToDyeColor(capturingTeam.getColor()).getWoolData() : -1; byte color2 = team != null ? MiscUtil.convertChatColorToDyeColor(team.getColor()).getWoolData() : -1; Vector center = progress.getCenterBlock().getVector(); double x = center.getX(); double z = center.getZ(); double percent = Math.toRadians(getPercent() * 3.6); for(Block block : progress.getBlocks()) { if (!visualMaterials.evaluate(block).equals(FilterState.ALLOW)) continue; double dx = block.getX() - x; double dz = block.getZ() - z; double angle = Math.atan2(dz, dx); if(angle < 0) angle += 2 * Math.PI; byte color = angle < percent ? color1 : color2; if (color == -1) { Pair<Material,Byte> oldBlock = oldProgress.getBlockAt(new BlockVector(block.getLocation().position())); if (oldBlock.getLeft().equals(block.getType())) color = oldBlock.getRight(); } if (color != -1) block.setData(color); } }
Example 3
Source File: CraftBlockState.java From Thermos with GNU General Public License v3.0 | 6 votes |
public CraftBlockState(final Block block) { this.world = (CraftWorld) block.getWorld(); this.x = block.getX(); this.y = block.getY(); this.z = block.getZ(); this.type = block.getTypeId(); this.light = block.getLightLevel(); this.chunk = (CraftChunk) block.getChunk(); this.flag = 3; // Cauldron start - save TE data TileEntity te = world.getHandle().getTileEntity(x, y, z); if (te != null) { nbt = new NBTTagCompound(); te.writeToNBT(nbt); } else nbt = null; // Cauldron end createData(block.getData()); }
Example 4
Source File: NMSHandler.java From askyblock with GNU General Public License v2.0 | 5 votes |
@Override public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) { net.minecraft.server.v1_9_R2.World w = ((CraftWorld) b.getWorld()).getHandle(); net.minecraft.server.v1_9_R2.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4); BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ()); int combined = blockId + (data << 12); IBlockData ibd = net.minecraft.server.v1_9_R2.Block.getByCombinedId(combined); if (applyPhysics) { w.setTypeAndData(bp, ibd, 3); } else { w.setTypeAndData(bp, ibd, 2); } chunk.a(bp, ibd); }
Example 5
Source File: BlockListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent e) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is BlockPistonExtendEvent event"); if (RedProtect.get().config.configRoot().performance.disable_PistonEvent_handler) { return; } Block piston = e.getBlock(); List<Block> blocks = e.getBlocks(); Region pr = RedProtect.get().rm.getTopRegion(piston.getLocation()); Boolean antih = RedProtect.get().config.configRoot().region_settings.anti_hopper; World w = e.getBlock().getWorld(); for (Block b : blocks) { RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockPistonExtendEvent event - Block: " + b.getType().name()); RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockPistonExtendEvent event - Relative: " + b.getRelative(e.getDirection()).getType().name()); Region br = RedProtect.get().rm.getTopRegion(b.getRelative(e.getDirection()).getLocation()); if (pr == null && br != null || (pr != null && br != null && pr != br && !pr.sameLeaders(br))) { e.setCancelled(true); return; } if (antih) { int x = b.getX(); int y = b.getY(); int z = b.getZ(); Block ib = w.getBlockAt(x, y + 1, z); if (!cont.canWorldBreak(ib) || !cont.canWorldBreak(b)) { e.setCancelled(true); return; } } } }
Example 6
Source File: NMSHandler.java From askyblock with GNU General Public License v2.0 | 5 votes |
@Override public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) { net.minecraft.server.v1_8_R3.World w = ((CraftWorld) b.getWorld()).getHandle(); net.minecraft.server.v1_8_R3.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4); BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ()); int combined = blockId + (data << 12); IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getByCombinedId(combined); if (applyPhysics) { w.setTypeAndData(bp, ibd, 3); } else { w.setTypeAndData(bp, ibd, 2); } chunk.a(bp, ibd); }
Example 7
Source File: CraftBlock.java From Thermos with GNU General Public License v3.0 | 5 votes |
public BlockFace getFace(final Block block) { BlockFace[] values = BlockFace.values(); for (BlockFace face : values) { if ((this.getX() + face.getModX() == block.getX()) && (this.getY() + face.getModY() == block.getY()) && (this.getZ() + face.getModZ() == block.getZ()) ) { return face; } } return null; }
Example 8
Source File: CraftHanging.java From Thermos with GNU General Public License v3.0 | 5 votes |
public boolean setFacingDirection(BlockFace face, boolean force) { Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing()); net.minecraft.entity.EntityHanging hanging = getHandle(); int x = hanging.field_146063_b, y = hanging.field_146064_c, z = hanging.field_146062_d, dir = hanging.hangingDirection; hanging.field_146063_b = block.getX(); hanging.field_146064_c = block.getY(); hanging.field_146062_d = block.getZ(); switch (face) { case SOUTH: default: getHandle().setDirection(0); break; case WEST: getHandle().setDirection(1); break; case NORTH: getHandle().setDirection(2); break; case EAST: getHandle().setDirection(3); break; } if (!force && !hanging.onValidSurface()) { // Revert since it doesn't fit hanging.field_146063_b = x; hanging.field_146064_c = y; hanging.field_146062_d = z; hanging.setDirection(dir); return false; } return true; }
Example 9
Source File: SimpleHologram.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private static ArmorStand getArmorStand(Block b, boolean createIfNoneExists) { Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() + 0.7F, b.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { if (n instanceof ArmorStand && n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) { return (ArmorStand) n; } } if (!createIfNoneExists) return null; else return create(l); }
Example 10
Source File: PlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
/** * Checks whether this shop uses the indicated chest. * * @param chest * the chest to check * @return */ public boolean usesChest(Block chest) { if (!chest.getWorld().getName().equals(worldName)) return false; int x = chest.getX(); int y = chest.getY(); int z = chest.getZ(); if (x == chestX && y == chestY && z == chestZ) return true; if (x == chestX + 1 && y == chestY && z == chestZ) return true; if (x == chestX - 1 && y == chestY && z == chestZ) return true; if (x == chestX && y == chestY && z == chestZ + 1) return true; if (x == chestX && y == chestY && z == chestZ - 1) return true; return false; }
Example 11
Source File: ActiveMiner.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public ActiveMiner(IndustrialMiner miner, UUID owner, Block chest, Block[] pistons, Block start, Block end) { this.miner = miner; this.owner = owner; this.chest = chest; this.pistons = pistons; this.start = new BlockPosition(start); this.end = new BlockPosition(end); this.height = start.getY(); this.x = start.getX(); this.z = start.getZ(); }
Example 12
Source File: NMSImpl.java From TabooLib with MIT License | 5 votes |
@Override public void recalculate(Block block, Type lightType) { Object world = ((CraftWorld) block.getWorld()).getHandle(); Object position = new net.minecraft.server.v1_15_R1.BlockPosition(block.getX(), block.getY(), block.getZ()); if (is11400) { Object lightEngine = ((net.minecraft.server.v1_14_R1.WorldServer) world).getChunkProvider().getLightEngine(); if (((net.minecraft.server.v1_14_R1.LightEngineThreaded) lightEngine).a()) { sync(lightEngine, e -> { Object[] lightEngineLayers; if (lightType == Type.BLOCK) { ((LightEngineLayer) ((net.minecraft.server.v1_14_R1.LightEngineThreaded) lightEngine).a(net.minecraft.server.v1_14_R1.EnumSkyBlock.BLOCK)).a(Integer.MAX_VALUE, true, true); } else if (lightType == Type.SKY) { ((LightEngineLayer) ((net.minecraft.server.v1_14_R1.LightEngineThreaded) lightEngine).a(net.minecraft.server.v1_14_R1.EnumSkyBlock.SKY)).a(Integer.MAX_VALUE, true, true); } else { Object b = ((net.minecraft.server.v1_14_R1.LightEngineThreaded) lightEngine).a(net.minecraft.server.v1_14_R1.EnumSkyBlock.BLOCK); Object s = ((net.minecraft.server.v1_14_R1.LightEngineThreaded) lightEngine).a(net.minecraft.server.v1_14_R1.EnumSkyBlock.SKY); int maxUpdateCount = Integer.MAX_VALUE; int integer4 = maxUpdateCount / 2; int integer5 = ((LightEngineLayer) b).a(integer4, true, true); int integer6 = maxUpdateCount - integer4 + integer5; int integer7 = ((LightEngineLayer) s).a(integer6, true, true); if (integer5 == 0 && integer7 > 0) { ((LightEngineLayer) b).a(integer7, true, true); } } }); } } else { if (lightType == Type.SKY) { ((net.minecraft.server.v1_13_R2.WorldServer) world).c(net.minecraft.server.v1_13_R2.EnumSkyBlock.SKY, (net.minecraft.server.v1_13_R2.BlockPosition) position); } else if (lightType == Type.BLOCK) { ((net.minecraft.server.v1_13_R2.WorldServer) world).c(net.minecraft.server.v1_13_R2.EnumSkyBlock.BLOCK, (net.minecraft.server.v1_13_R2.BlockPosition) position); } else { ((net.minecraft.server.v1_13_R2.WorldServer) world).c(net.minecraft.server.v1_13_R2.EnumSkyBlock.SKY, (net.minecraft.server.v1_13_R2.BlockPosition) position); ((net.minecraft.server.v1_13_R2.WorldServer) world).c(net.minecraft.server.v1_13_R2.EnumSkyBlock.BLOCK, (net.minecraft.server.v1_13_R2.BlockPosition) position); } } }
Example 13
Source File: NMSImpl.java From TabooLib with MIT License | 5 votes |
@Override public int getRawLightLevel(Block block, Type lightType) { Object world = ((CraftWorld) block.getWorld()).getHandle(); Object position = new net.minecraft.server.v1_15_R1.BlockPosition(block.getX(), block.getY(), block.getZ()); if (lightType == Type.BLOCK) { return ((net.minecraft.server.v1_13_R2.WorldServer) world).getBrightness(net.minecraft.server.v1_13_R2.EnumSkyBlock.BLOCK, (net.minecraft.server.v1_13_R2.BlockPosition) position); } else if (lightType == Type.SKY) { return ((net.minecraft.server.v1_13_R2.WorldServer) world).getBrightness(net.minecraft.server.v1_13_R2.EnumSkyBlock.SKY, (net.minecraft.server.v1_13_R2.BlockPosition) position); } else { return ((net.minecraft.server.v1_13_R2.WorldServer) world).getLightLevel((net.minecraft.server.v1_13_R2.BlockPosition) position); } }
Example 14
Source File: Util.java From ObsidianDestroyer with GNU General Public License v3.0 | 4 votes |
public static boolean isTargetsPathBlocked(Location tLoc, Location dLoc, boolean useOnlyMaterialListing) { // check world if (!dLoc.getWorld().getName().equalsIgnoreCase(tLoc.getWorld().getName())) { return false; } // if the distance is too close... the path is not blocked ;) if (dLoc.distance(tLoc) <= 0.9) { return false; } // try to iterate through blocks between dLoc and tLoc try { // Create a vector block trace from the detonator location to damaged block's location final BlockIterator blocksInPath = new BlockIterator(tLoc.getWorld(), dLoc.toVector(), tLoc.toVector().subtract(dLoc.toVector()).normalize(), 0.5, (int) dLoc.distance(tLoc)); // iterate through the blocks in the path int over = 0; // prevents rare case of infinite loop and server crash while (blocksInPath.hasNext() && over < 128) { over++; // the next block final Block block = blocksInPath.next(); if (block == null) { continue; } // check if next block is the target block if (tLoc.getWorld().getName().equals(block.getWorld().getName()) && tLoc.getBlockX() == block.getX() && tLoc.getBlockY() == block.getY() && tLoc.getBlockZ() == block.getZ()) { // ignore target block continue; } // check if the block material is being handled if (useOnlyMaterialListing) { // only handle for certain case as to not interfere with all explosions if (MaterialManager.getInstance().contains(block.getType().name(), block.getData())) { return true; } else { continue; } } // check if the block material is a solid if (!isNonSolid(block.getType())) { return true; } } } catch (Exception e) { // ignore the error and return no targets in path } return false; }
Example 15
Source File: DPortal.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
/** * @param plugin the plugin instance * @param block a block covered by the returned portal * @return the portal that the block belongs to, null if it belongs to none */ public static DPortal getByBlock(DungeonsXL plugin, Block block) { for (GlobalProtection protection : plugin.getGlobalProtectionCache().getProtections(DPortal.class)) { DPortal portal = (DPortal) protection; if (portal.getBlock1() == null || portal.getBlock2() == null) { continue; } int x1 = portal.block1.getX(), y1 = portal.block1.getY(), z1 = portal.block1.getZ(); int x2 = portal.block2.getX(), y2 = portal.block2.getY(), z2 = portal.block2.getZ(); int x3 = block.getX(), y3 = block.getY(), z3 = block.getZ(); if (x1 > x2) { if (x3 < x2 || x3 > x1) { continue; } } else if (x3 > x2 || x3 < x1) { continue; } if (y1 > y2) { if (y3 < y2 || y3 > y1) { continue; } } else if (y3 > y2 || y3 < y1) { continue; } if (z1 > z2) { if (z3 < z2 || z3 > z1) { continue; } } else if (z3 > z2 || z3 < z1) { continue; } return portal; } return null; }
Example 16
Source File: BlockEventQuery.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public BlockEventQuery(Event event, Block block) { this(event, block.getWorld(), block.getX(), block.getY(), block.getZ(), null); }
Example 17
Source File: Wall.java From civcraft with GNU General Public License v2.0 | 4 votes |
private void validateBlockLocation(Player player, Location loc) throws CivException { Block b = loc.getBlock(); if (ItemManager.getId(b) == CivData.CHEST) { throw new CivException("Cannot build here, would destroy chest."); } TownChunk tc = CivGlobal.getTownChunk(b.getLocation()); if (tc != null && !tc.perms.hasPermission(PlotPermissions.Type.DESTROY, CivGlobal.getResident(player))) { // Make sure we have permission to destroy any block in this area. throw new CivException("Cannot build here, you need DESTROY permissions to the block at "+b.getX()+","+b.getY()+","+b.getZ()); } BlockCoord coord = new BlockCoord(b); //not building a trade outpost, prevent protected blocks from being destroyed. if (CivGlobal.getProtectedBlock(coord) != null) { throw new CivException("Cannot build here, protected blocks in the way."); } if (CivGlobal.getStructureBlock(coord) != null) { throw new CivException("Cannot build here, structure blocks in the way at "+coord); } if (CivGlobal.getFarmChunk(new ChunkCoord(coord.getLocation())) != null) { throw new CivException("Cannot build here, in the same chunk as a farm improvement."); } if (loc.getBlockY() >= Wall.MAX_HEIGHT) { throw new CivException("Cannot build here, wall is too high."); } if (loc.getBlockY() <= 1) { throw new CivException("Cannot build here, too close to bedrock."); } BlockCoord bcoord = new BlockCoord(loc); for (int y = 0; y < 256; y++) { bcoord.setY(y); StructureBlock sb = CivGlobal.getStructureBlock(bcoord); if (sb != null) { throw new CivException("Cannot build here, this wall segment overlaps with a structure block belonging to a "+sb.getOwner().getName()+" structure."); } } }
Example 18
Source File: ContainerManager.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public boolean canWorldBreak(Block b) { if (!RedProtect.get().config.configRoot().private_cat.use) { return true; } Region reg = RedProtect.get().rm.getTopRegion(b.getLocation()); if (reg == null && !RedProtect.get().config.configRoot().private_cat.allow_outside) { return true; } int x = b.getX(); int y = b.getY(); int z = b.getZ(); World w = b.getWorld(); if (isSign(b) && validWorldBreak(b)) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Valid Sign on canWorldBreak!"); return false; } String signbtype = b.getType().name(); List<String> blocks = RedProtect.get().config.configRoot().private_cat.allowed_blocks; if (blocks.stream().anyMatch(signbtype::matches)) { for (int sx = -1; sx <= 1; sx++) { for (int sz = -1; sz <= 1; sz++) { Block bs = w.getBlockAt(x + sx, y, z + sz); if (isSign(bs) && validWorldBreak(bs)) { return false; } String blocktype2 = b.getType().name(); int x2 = bs.getX(); int y2 = bs.getY(); int z2 = bs.getZ(); if (blocks.stream().anyMatch(blocktype2::matches)) { for (int ux = -1; ux <= 1; ux++) { for (int uz = -1; uz <= 1; uz++) { Block bu = w.getBlockAt(x2 + ux, y2, z2 + uz); if (isSign(bu) && validWorldBreak(bu)) { return false; } } } } } } } return true; }
Example 19
Source File: ContainerManager.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public boolean canBreak(Player p, Block b) { if (!RedProtect.get().config.configRoot().private_cat.use || p.hasPermission("redprotect.bypass")) { return true; } Region reg = RedProtect.get().rm.getTopRegion(b.getLocation()); if (reg == null && !RedProtect.get().config.configRoot().private_cat.allow_outside) { return true; } int x = b.getX(); int y = b.getY(); int z = b.getZ(); World w = p.getWorld(); boolean deny = true; if (isSign(b) && validatePrivateSign(b)) { deny = false; if (validateBreakSign(b, p)) { return true; } } String signbtype = b.getType().name(); List<String> blocks = RedProtect.get().config.configRoot().private_cat.allowed_blocks; if (blocks.stream().anyMatch(signbtype::matches)) { for (int sx = -1; sx <= 1; sx++) { for (int sy = -1; sy <= 1; sy++) { for (int sz = -1; sz <= 1; sz++) { Block bs = w.getBlockAt(x + sx, y + sy, z + sz); if (isSign(bs) && (validatePrivateSign(bs))) { deny = false; if (validateBreakSign(bs, p)) { return true; } } String blocktype2 = b.getType().name(); int x2 = bs.getX(); int y2 = bs.getY(); int z2 = bs.getZ(); if (blocks.stream().anyMatch(blocktype2::matches)) { for (int ux = -1; ux <= 1; ux++) { for (int uy = -1; uy <= 1; uy++) { for (int uz = -1; uz <= 1; uz++) { Block bu = w.getBlockAt(x2 + ux, y2 + uy, z2 + uz); if (isSign(bu) && (validatePrivateSign(bu))) { deny = false; if (validateBreakSign(bu, p)) { return true; } } } } } } } } } } return deny; }
Example 20
Source File: BlockIterator.java From Kettle with GNU General Public License v3.0 | 4 votes |
private boolean blockEquals(Block a, Block b) { return a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ(); }