Solved Call function in NMS block

Discussion in 'Plugin Development' started by epicfacecreeper, Dec 18, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    epicfacecreeper

    I need to call the grow() method in BlockSapling. How do I get the instance of that block?
     
  2. Offline

    NathanWolf

    It looks like you could call "getNMSBlock" on CraftBlock, but it's private, so you'd have to use reflection to make it accessible (I think).

    https://github.com/Bukkit/CraftBukk.../bukkit/craftbukkit/block/CraftBlock.java#L49

    https://github.com/Bukkit/CraftBukk...n/java/net/minecraft/server/BlockSapling.java

    I'm not an expert, though, maybe there's a better way!

    EDIT: Maybe a better way is to do what getNMSBlock does and call CraftMagicNumbers.getBlock(block); This looks pretty easy, you only need to tie into OBC.CraftMagicNumbers and NMS.BlockSapling.

    https://github.com/Bukkit/CraftBukk...ukkit/craftbukkit/util/CraftMagicNumbers.java
     
  3. Offline

    epicfacecreeper

    Actually, I figured it out myself. You can call getType() in nms.World to get the block, which you can perform operations on.
     
Thread Status:
Not open for further replies.

Share This Page