Solved [NMS] Get number of snow layers prior to MC 1.13

Discussion in 'Spigot Plugin Development' started by UniverseCraft, Mar 8, 2020.

  1. I'm working on a multi-version Spigot plugin and am trying to implement an NMS-based method to find the number of layers of a block of snow.

    In 1.13 the Spigot API Block.getBlockData() method was added, which can be casted to Snow, which has the convenient getLayers() function. Prior to this, however, there is no such method.

    I'm no NMS wizard, but my approach has been deobfuscating the relevant NMS classes: [BlockSnow, Block, BlockData, etc. All I've found is the static LAYERS variable in the BlockSnow class, and I'm unsure of how to use it.

    I'm currently getting the NMS block using
    Code (Text):
    CraftMagicNumbers.getBlock(spigotBlock)
    but looking at the deobfuscated NMS code, it seems like this just returns a general block of the same type, rather than an NMS block representing that specific Spigot block.

    Any ideas? Or, is there a resource someone could point me toward that explains this?
     
  2. block.getData() ?
     
  3. You'll have to use the deprecated Block#getData. Here's a list of what height the data values represent, though it's fairly straightforward.
     
    • Funny Funny x 1
  4. Thank you kindly. Marking as solved.
     
  5. Why not using Snow ?

    Block#getBlockData()
    check in blockData instance of Snow
    cast it to Snow
    get your level.
     
  6. Choco

    Moderator

    Pre-1.13. Old software, old, deprecated methods.
     
  7. I would guess 1.8.x guys that do not know that new and easy API's exist....
    Screenshot 2020-03-08 at 14.41.18.png



    EDIT: F**k #prior. Skipping question and a big part of the title.... My bad.

    EDIT 2: # Selective attention
     
    • Like Like x 1
    • Funny Funny x 1