/** * Generates up to 64 flowers around the given point. */ @Override public boolean generate(World world, Random random, int sourceX, int sourceY, int sourceZ) { boolean succeeded = false; for (int i = 0; i < 64; i++) { int x = sourceX + random.nextInt(8) - random.nextInt(8); int z = sourceZ + random.nextInt(8) - random.nextInt(8); int y = sourceY + random.nextInt(4) - random.nextInt(4); Block block = world.getBlockAt(x, y, z); if (y < 255 && block.getType() == Material.AIR && block.getRelative(BlockFace.DOWN).getType() == Material.GRASS) { block.setType(type); block.setData((byte) data); succeeded = true; } } return succeeded; } }
@Override public void setData(final byte data, boolean applyPhysics) { base.setData(data, applyPhysics); }
@Override public void setData(final byte data) { base.setData(data); }
public static void setData_Block(Block block, byte data) { block.setData(data); }
/** * Sets the Material Data for a Block * * @param block to set it for * @param materialData to set to * @param doPhysics - True to perform physics, False for 'silent' */ @SuppressWarnings("deprecation") public static void setData(org.bukkit.block.Block block, MaterialData materialData, boolean doPhysics) { block.setData(materialData.getData(), doPhysics); }
/** * Sets the Material Data for a Block * * @param block to set it for * @param materialData to set to */ @SuppressWarnings("deprecation") public static void setData(org.bukkit.block.Block block, MaterialData materialData) { block.setData(materialData.getData()); }
public void setType(final Material material, final byte data) { this.newdata = data; this.block.setType(material); this.block.setData(data); }
public AbstractBlock readBlock(int blockNum, AbstractDBFile f) throws IOException { DBFile dbf = (DBFile) f; byte[] data2 = new byte[4096]; RandomAccessFile file = new RandomAccessFile(dbf.fileName, "r"); file.seek(4096+blockNum*4096); Block b = new Block(); for (int i = 0; i < 4096; i++){ try{ data2[i] = file.readByte(); }catch(EOFException ex){ System.out.println("End of file reached!"); //break the loop break; } } file.close(); b.setData(data2); return b; }
public static void revertSand(final Block block) { final MaterialData materialdata = SAND_ID_ENTITIES.get(block); SAND_ID_ENTITIES.remove(block); SAND_BLOCKS.remove(block); if (block.getType() == Material.SAND) { block.setType(materialdata.getItemType()); block.setData(materialdata.getData()); } }
public static void removeBlock(final Block block) { if (IGNITED_BLOCKS.containsKey(block)) { IGNITED_BLOCKS.remove(block); } if (IGNITED_TIMES.containsKey(block)) { IGNITED_TIMES.remove(block); } if (REPLACED_BLOCKS.containsKey(block.getLocation())) { block.setType(REPLACED_BLOCKS.get(block.getLocation()).getItemType()); block.setData(REPLACED_BLOCKS.get(block.getLocation()).getData()); REPLACED_BLOCKS.remove(block.getLocation()); } }
@Override public void remove() { super.remove(); for (final Block b : this.waterOrigins.keySet()) { if (b.getType() == Material.AIR) { b.setType(this.waterOrigins.get(b).getItemType()); b.setData(this.waterOrigins.get(b).getData()); } } }
public static void revertBlock(final Block block, final Material defaulttype) { if (instances.containsKey(block)) { instances.get(block).revertBlock(); } else { if ((defaulttype == Material.LAVA || defaulttype == Material.STATIONARY_LAVA) && GeneralMethods.isAdjacentToThreeOrMoreSources(block)) { block.setType(Material.LAVA); block.setData((byte) 0x0); } else if ((defaulttype == Material.WATER || defaulttype == Material.STATIONARY_WATER) && GeneralMethods.isAdjacentToThreeOrMoreSources(block)) { block.setType(Material.WATER); block.setData((byte) 0x0); } else { block.setType(defaulttype); } } }
public static void removeBlock(final Block block) { if (isAdjacentToThreeOrMoreSources(block)) { block.setType(Material.WATER); block.setData((byte) 0x0); } else { block.setType(Material.AIR); } }
@SuppressWarnings("deprecation") @Override public void run(String playerID) throws QuestRuntimeException { Location location = loc.getLocation(playerID); location.getBlock().setType(block); location.getBlock().setData(data); }
@EventHandler public void onInteractEvent(PlayerInteractEvent e) { Block interacted = e.getClickedBlock(); //Check if this is the block you want Block block= interacted.getRelative(BlockFace.UP, 1); //Can be changed to any block face, and any distance switch(block.getType()) { case LEVER: case REDSTONE: case DISPENSER: case POWERED_RAILS: case whatever other blocks can be powered: { block.setData(block.getData() | 0x8); // sets the 0x8 bit to the data, making it powered } }
@Override public void remove() { super.remove(); if (this.block.getType() == Material.AIR) { this.block.setType(this.type); this.block.setData(this.data); if (this.type == Material.DOUBLE_PLANT) { this.block.getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT); this.block.getRelative(BlockFace.UP).setData((byte) 10); } } else { GeneralMethods.dropItems(this.block, GeneralMethods.getDrops(this.block, this.type, this.data, null)); } }
@Override public void remove() { super.remove(); if (this.destination != null && this.sourceBlock != null) { this.sourceBlock.setType(Material.AIR); } else if (this.sourceBlock != null) { if (this.sourceBlock.getType() == Material.SAND) { if (this.sourceBlock.getData() == (byte) 0x1) { this.sourceBlock.setType(this.sourceType); this.sourceBlock.setData((byte) 0x1); } else { this.sourceBlock.setType(this.sourceType); } } else { this.sourceBlock.setType(this.sourceType); this.sourceBlock.setData(this.sourceData); } } }
/** * Gets a {@code Collection<ItemStack>} of item drops from a single block. * * @param block The single block * @param type The Material type to change the block into * @param data The block data to change the block into * @param breakitem Unused * @return The item drops fromt the specified block */ public static Collection<ItemStack> getDrops(final Block block, final Material type, final byte data, final ItemStack breakitem) { final BlockState tempstate = block.getState(); block.setType(type); block.setData(data); final Collection<ItemStack> item = block.getDrops(); tempstate.update(true); return item; }
@Override public void run() { button.setPowered(!button.isPowered()); btBlock.setData(button.getData()); final Block supportBlock = btBlock.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState(); final BlockState supportState = supportBlock.getState(); supportState.setType(Material.AIR); supportState.update(true, false); initialSupportState.update(true); } } }.runTaskLater(ProjectKorra.plugin, 10);
@Override public void run() { button.setPowered(!button.isPowered()); btBlock.setData(button.getData()); final Block supportBlock = btBlock.getRelative(button.getAttachedFace()); if (supportBlock != null && supportBlock.getType() != Material.AIR) { final BlockState initialSupportState = supportBlock.getState(); final BlockState supportState = supportBlock.getState(); supportState.setType(Material.AIR); supportState.update(true, false); initialSupportState.update(true); } } }.runTaskLater(ProjectKorra.plugin, 15);