setTypeIdAndData deprecated, need way of converting Byte data into Material

Discussion in 'Plugin Development' started by Caedus, Jun 29, 2020.

  1. Offline

    Caedus

    Hi,

    I've been looking at implement this https://bukkit.org/threads/pasting-loading-schematics.87129/ code into my plugin. Unfortunately, the method setTypeIdAndData is deprecated so I need to find another way. In the solutions I have found online, people suggest using BlockData instead.

    This solution should work fine, but I need a way of converting the existing byte data I have (which the code pulls from the schematic) into a Material. Is there a way of doing this? Perhaps an inbuilt functionality I have missed?

    Cheers
     
  2. Offline

    KarimAKL

    @Caedus You can set the BlockData using:
    https://hub.spigotmc.org/javadocs/s...Data-org.bukkit.block.data.BlockData-boolean-

    Version 1.13 removed item IDs so no, there's no way to do that.
    If you're using a version below 1.13, you'll have the Material#getMaterial(int id) method.
     
    Last edited: Jun 29, 2020
  3. Offline

    Caedus

    Unless blockdata is now stored different in schematics, how do WorldEdit and other APIs correctly interpret & paste byte data into blocks? It must still be possible somehow, right?
     
  4. Offline

    KarimAKL

    @Caedus Although it's deprecated, you should still be able to use BlockState#getRawData() and BlockState#setRawData(byte).
     

Share This Page