Solved How do I query a blockid like pink wool?

Discussion in 'Spigot Plugin Development' started by Italien1, Jan 19, 2020.

  1. @EventHandler
    public void onPlace(BlockPlaceEvent event){
    final Block block2 = event.getBlock();
    Player p = event.getPlayer();
    Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
    public void run() {
    if(p.isOp()) {

    } else {
    if (event.getBlock().getType().equals(Material.WOOL)) {
    p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1f, 1f);
    p.sendMessage("§6§lWSystem > §f§4Dir ist es untersagt wolle zu Plazieren damit keine Wolle Rakete gebaut wird!");
    }, 0*20L);
  2. You would have to compare both the Material of a block and the durability. Since pink wool has id 35:6, the material is like the 35 part and the durabililty is the :6 part.
  3. Use a code block.
    And, what is your question?
  4. event.getBlock().getDurability()

    In game, do F3 + H to view the IDs.
    • Winner Winner x 1
  5. event.getBlock().getDurability(35:6) ??
  6. event.getBlock().getDurability() returns the data of the item. If the item is pink wool it will return 6. I'm trying to not spoon feed you here as you will not learn from being spoonfed.
    • Like Like x 1
  7. Just upgrade to 1.15.1 and let your issue be the past.

    Code (Text):
    if(block.getType() == Material.WOOL && block.getData() == 6){

  8. This is not even valid Java
  9. Block#getDurability doesn't exist (at least not now, maybe it was removed, idk)
  10. In 1.13+ nothing like that is present. Why should it. xD
  11. Sorry, I'm getting mixed up. Try event.getBlock().getData() If the block is pink wool this should return 6. I just tested it, in 10.2.
    • Winner Winner x 1
  12. Was trying to avoid spoonfeeding them that lol.
    • Like Like x 1
    • Funny Funny x 1
  13. With outdated MC version spoon-feeding doesn't matter. Everything from 1.13+ is so easy that spoon-feeding should be avoided.

    In exchange I could say "That's basic Java knowledge. Try learning Java first". xD
  14. Not wrong... I guess lol
    • Creative Creative x 1