Get and set the Grass Species.

Discussion in 'Spigot Help' started by iFighter, Jun 12, 2017.

  1. Hey guys, i want to save a few blocks in a json file. I noticed that every grass species has the same Material type. Now i want to get the species of a block and set it again later but nothing i tried worked.
     
  2. If you want to make a plugin with these features, I suggest you to post this in the Plugin Development forum^
     
  3. The type is stored as the durability/data of the block.
    Same with a lot of blocks, for example stone with a durability of 0 is smooth stone, 1 to 8 are andesite, granite, polished andesite, etc
     
  4. Ty, but i am not quite sure how i have to implement this. I tried setting the block state and updating the block but it didn't work. It would be great if you could provide my a litle code sample.
     
  5. For an item (in your inventory) its ItemStack#getDurability and ItemStack#setDurability(x)
    For a block (in the world) its Block.getData() and Block.setData(x)
     
  6. setData(material, data) is deprecated and even if i use it it doesn't work for me.

    Code (Text):
    block.getState().setData(new MaterialData(Material.GRASS, (byte) 0));
    block.getState().update();
     
  7. Why the fuck are you using the state?
    I said Block#setData, not BlockState#setData