Solved Getting IBlockData from a Bukkit Material. (NMS)

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

  1. Does anyone know how to do the above?
     
  2. What is the final goal you are trying to achieve?
     
  3. Not 100% certain, but I think you could do something like:

    Code (Java):
    public IBlockData fromMaterial(Material m) {
        net.minecraft.server.v1_13_R2.Block nmsBlock = CraftMagicNumbers.getBlock(cm);
        return nmsBlock.getBlockData();
    }
    or, from a block:

    Code (Java):
    public IBlockData fromBlock(Block m) {
        net.minecraft.server.v1_13_R2.World nmsWorld = ((org.bukkit.craftbukkit.v1_13_R2.CraftWorld)block.getWorld()).getHandle().getMinecraftWorld();
        BlockPosition bp = new BlockPosition(block.getX(), block.getY(), block.getZ());
        return nmsWorld.getType(bp);
    }
     
    • Like Like x 3
    • Useful Useful x 1
  4. Thanks Universe, I'll give it a go.