Java Code Examples for org.bukkit.block.Block#getTypeId()
The following examples show how to use
org.bukkit.block.Block#getTypeId() .
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: BlockImage.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
/** Set every block in this image to its current state in the world */ @SuppressWarnings("deprecation") public void save() { if (this.blockCounts != null) { this.blockCounts.clear(); } int offset = 0; for (BlockVector v : this.bounds.getBlocks()) { Block block = this.world.getBlockAt(v.getBlockX(), v.getBlockY(), v.getBlockZ()); this.blockIds[offset] = (short) block.getTypeId(); this.blockData[offset] = block.getData(); ++offset; if (this.blockCounts != null) { MaterialData md = block.getState().getData(); this.blockCounts.put(md, this.blockCounts.get(md) + 1); } } }
Example 2
Source File: CraftBlockState.java From Kettle 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.chunk = (CraftChunk) block.getChunk(); this.flag = 3; createData(block.getData()); TileEntity te = world.getHandle().getTileEntity(new BlockPos(this.x, this.y, this.z)); if (te != null) { nbt = new NBTTagCompound(); te.writeToNBT(nbt); } else nbt = null; }
Example 3
Source File: BlockImage.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
/** * Set every block in this image to its current state in the world */ @SuppressWarnings("deprecation") public void save() { if(this.blockCounts != null) { this.blockCounts.clear(); } int offset = 0; for(Vec3 v : this.bounds.blockRegion().mutableIterable()) { Block block = this.world.getBlockAt(v.coarseX(), v.coarseY(), v.coarseZ()); this.blockIds[offset] = (short) block.getTypeId(); this.blockData[offset] = block.getData(); ++offset; if(this.blockCounts != null) { MaterialData md = block.getState().getData(); this.blockCounts.put(md, this.blockCounts.get(md) + 1); } } }
Example 4
Source File: BukkitBlockConnectionProvider.java From ViaVersion with MIT License | 6 votes |
@Override public int getWorldBlockData(UserConnection user, int bx, int by, int bz) { UUID uuid = user.getProtocolInfo().getUuid(); Player player = Bukkit.getPlayer(uuid); if (player != null) { World world = player.getWorld(); int x = bx >> 4; int z = bz >> 4; if (world.isChunkLoaded(x, z)) { Chunk c = getChunk(world, x, z); Block b = c.getBlock(bx, by, bz); return b.getTypeId() << 4 | b.getData(); } } return 0; }
Example 5
Source File: CraftLivingEntity.java From Thermos with GNU General Public License v3.0 | 6 votes |
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) { if (maxDistance > 120) { maxDistance = 120; } ArrayList<Block> blocks = new ArrayList<Block>(); Iterator<Block> itr = new BlockIterator(this, maxDistance); while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); if (maxLength != 0 && blocks.size() > maxLength) { blocks.remove(0); } int id = block.getTypeId(); if (transparent == null) { if (id != 0) { break; } } else { if (!transparent.contains((byte) id)) { break; } } } return blocks; }
Example 6
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 7
Source File: FaweAdapter_1_10.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public BaseBlock getBlock(Location location) { Preconditions.checkNotNull(location); CraftWorld craftWorld = (CraftWorld)location.getWorld(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); Block bukkitBlock = location.getBlock(); BaseBlock block = new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z)); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); block.setNbtData((CompoundTag)toNative(tag)); } return block; }
Example 8
Source File: FaweAdapter_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public BaseBlock getBlock(Location location) { Preconditions.checkNotNull(location); CraftWorld craftWorld = (CraftWorld)location.getWorld(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); Block bukkitBlock = location.getBlock(); BaseBlock block = new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z)); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); block.setNbtData((CompoundTag)toNative(tag)); } return block; }
Example 9
Source File: FaweAdapter_1_9.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public BaseBlock getBlock(Location location) { Preconditions.checkNotNull(location); CraftWorld craftWorld = (CraftWorld)location.getWorld(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); Block bukkitBlock = location.getBlock(); BaseBlock block = new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z)); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); block.setNbtData((CompoundTag)toNative(tag)); } return block; }
Example 10
Source File: FaweAdapter_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public BaseBlock getBlock(Location location) { Preconditions.checkNotNull(location); CraftWorld craftWorld = (CraftWorld)location.getWorld(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); Block bukkitBlock = location.getBlock(); BaseBlock block = new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z)); if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); block.setNbtData((CompoundTag)toNative(tag)); } return block; }
Example 11
Source File: BukkitWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BaseBlock getBlock(Vector position) { BukkitImplAdapter adapter = BukkitQueue_0.getAdapter(); if (adapter != null) { return adapter.getBlock(adapt(getWorld(), position)); } else { Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); return new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData()); } }
Example 12
Source File: BukkitWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public BaseBlock getLazyBlock(Vector position) { World world = getWorld(); Block bukkitBlock = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); return new LazyBlock(bukkitBlock.getTypeId(), bukkitBlock.getData(), this, position); }
Example 13
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static BlockPhysicsEvent callBlockPhysicsEvent(World world, BlockPos blockposition) { Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId()); world.getServer().getPluginManager().callEvent(event); return event; }
Example 14
Source File: ItemManager.java From civcraft with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public static int getId(Block block) { return block.getTypeId(); }
Example 15
Source File: IslandBlock.java From askyblock with GNU General Public License v2.0 | 4 votes |
/** * Paste this block at blockLoc * @param nms * @param blockLoc */ //@SuppressWarnings("deprecation") @SuppressWarnings("deprecation") public void paste(NMSAbstraction nms, Location blockLoc, boolean usePhysics, Biome biome) { // Only paste air if it is below the sea level and in the overworld Block block = new Location(blockLoc.getWorld(), x, y, z).add(blockLoc).getBlock(); block.setBiome(biome); nms.setBlockSuperFast(block, typeId, data, usePhysics); if (signText != null) { if (block.getTypeId() != typeId) { block.setTypeId(typeId); } // Sign Sign sign = (Sign) block.getState(); int index = 0; for (String line : signText) { sign.setLine(index++, line); } sign.update(true, false); } else if (banner != null) { banner.set(block); } else if (skull != null){ skull.set(block); } else if (pot != null){ pot.set(nms, block); } else if (spawnerBlockType != null) { if (block.getTypeId() != typeId) { block.setTypeId(typeId); } CreatureSpawner cs = (CreatureSpawner)block.getState(); cs.setSpawnedType(spawnerBlockType); //Bukkit.getLogger().info("DEBUG: setting spawner"); cs.update(true, false); } else if (!chestContents.isEmpty()) { if (block.getTypeId() != typeId) { block.setTypeId(typeId); } //Bukkit.getLogger().info("DEBUG: inventory holder "+ block.getType()); // Check if this is a double chest InventoryHolder chestBlock = (InventoryHolder) block.getState(); //InventoryHolder iH = chestBlock.getInventory().getHolder(); if (chestBlock instanceof DoubleChest) { //Bukkit.getLogger().info("DEBUG: double chest"); DoubleChest doubleChest = (DoubleChest) chestBlock; for (ItemStack chestItem: chestContents.values()) { doubleChest.getInventory().addItem(chestItem); } } else { // Single chest for (Entry<Byte, ItemStack> en : chestContents.entrySet()) { //Bukkit.getLogger().info("DEBUG: " + en.getKey() + "," + en.getValue()); chestBlock.getInventory().setItem(en.getKey(), en.getValue()); } } } }