public boolean matches(Block block) { return block.getType() == getType() && block.getData() == getData(); }
/** * Test whether this pattern matches a block. * @param location the base location * @param xz TODO: document this parameter * @param y TODO: document this parameter * @param alignment TODO: document this parameter * @return true if this pattern matches; false otherwise */ public Location[] matches(Location location, int xz, int y, Alignment alignment) { int i = 0; Location[] r = new Location[blocks.length]; for (PatternItem block : blocks) { int dxz = block.xz - xz; int dy = block.y - y; Location relative = location.clone() .add(dxz * alignment.x, -dy, dxz * alignment.z); if (relative.getBlock().getType() != block.getType() || ( (relative.getBlock().getData() != block.getData()) && block.getData() != -1)) { return null; } r[i++] = relative; } return r; }
private void checkBlock(Block b, String trigger) { BlockToCheck btt = new BlockToCheck(); btt.loc = b.getLocation(); btt.typeid = b.getTypeId(); btt.data = b.getData(); btt.trigger = trigger; blocks_to_check_accum.add(btt); /* Add to accumulator */ btth.startIfNeeded(); }
/** * Get the (legacy) data value for the block. * * @param block * the block * @return the data */ public static int getData(final Block block) { return block.getData(); }
public void run() { BlockToCheck btt; while(blocks_to_check.isEmpty() != true) { btt = blocks_to_check.pop(); Location loc = btt.loc; World w = loc.getWorld(); if(!w.isChunkLoaded(loc.getBlockX()>>4, loc.getBlockZ()>>4)) continue; int bt = w.getBlockTypeIdAt(loc); /* Avoid stationary and moving water churn */ if(bt == 9) bt = 8; if(btt.typeid == 9) btt.typeid = 8; if((bt != btt.typeid) || (btt.data != w.getBlockAt(loc).getData())) { String wn = getWorld(w).getName(); sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), btt.trigger); } } blocks_to_check = null; /* Kick next run, if one is needed */ startIfNeeded(); } public void startIfNeeded() {
@SuppressWarnings("deprecation") @Override public int fetchData(final int x, final int y, final int z) { // TODO: consider setting type id and data at once. return world.getBlockAt(x, y, z).getData(); }
/** * @param block */ public BlockTypeEntry(Block block) { this.material = block.getType(); this.data = block.getData(); }
@SuppressWarnings("deprecation") public void modifyFast(Block block) { Material material = this.material == null ? block.getType() : this.material; int data = this.data == null ? block.getData() : this.data; if (material != block.getType() || data != block.getData()) { CompatibilityUtils.setBlockFast(block, material, data); } }
public static boolean isLavabendable(final Player player, final Block block) { final byte full = 0x0; if (TempBlock.isTempBlock(block)) { final TempBlock tblock = TempBlock.instances.get(block); if (tblock == null || !LavaFlow.getTempLavaBlocks().values().contains(tblock)) { return false; } } if (isLava(block) && block.getData() == full) { return true; } return false; }
/** * @param block */ public BlockEntry(Block block) { this.typeId = block.getTypeId(); this.data = block.getData(); this.location = block.getLocation(); }
@Override @SuppressWarnings("deprecation") public boolean check(String playerID) throws QuestRuntimeException { Block block = loc.getLocation(playerID).getBlock(); if (data.isPresent()) { return (block.getType() == material && block.getData() == data.get()); } else { return (block.getType() == material); } }
public void revertGlowBlock() { if (this.block != null) { this.player.sendBlockChange(this.block.getLocation(), this.block.getTypeId(), this.block.getData()); } }
@SuppressWarnings ("deprecation") public static void clear(Player player) { Set<Location> locations = getPlayerLocations(player); if (locations == null) { return; } for (Location location : locations) { Block block = location.getWorld().getBlockAt(location); player.sendBlockChange(location, block.getType(), block.getData()); } locations.clear(); }
public void debugEnd() { for (Player player : Bukkit.getOnlinePlayers()) { for (PathEntry entry : path) { Block block = entry.vector.toLocation(player.getWorld()).getBlock(); player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); } } }
/** * @param block */ public TranslocationBlock(Block block) { super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()); this.type = new BlockTypeEntry(block.getTypeId(), block.getData()); }
/** * @param block */ public Unbreakable(Block block) { super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()); this.type = new BlockTypeEntry(block.getTypeId(), block.getData()); this.dirty = true; }
/** * @param block */ public GriefBlock(Block block) { super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()); this.type = new BlockTypeEntry(block.getTypeId(), block.getData()); }
/** * @param block */ public TranslocationBlock(Field field, Block block) { super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()); this.type = new BlockTypeEntry(block.getTypeId(), block.getData()); setRelativeCoords(field); }
@Override @SuppressWarnings("deprecation") public void hide() { temp.setWorld(world); temp.setX(position.getX()); temp.setY(position.getY()); temp.setZ(position.getZ()); send(temp.getBlock().getType(), temp.getBlock().getData()); super.hide(); }