Nms

Discussion in 'Plugin Development' started by AlbkadDev, Aug 9, 2017.

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

    AlbkadDev

    So I am trying to use NMS code and I thnk I am doing it right it is just that I need to know how to specify a minecraft block (Not bukkit block) couse I cant seem to find a list of the blocks. I want to know what to put in the object bar. (I am changing block strength of a specific block). 1.8

    Code:
            try {
              
                Field field = net.minecraft.server.v1_8_R1.Block.class.getDeclaredField("strength");
                field.setAccessible(true);
              
                field.setFloat(obj, 50);
              
            } catch (NoSuchFieldException | SecurityException e) {
                e.printStackTrace();
            }
     
    Last edited: Aug 9, 2017
  2. Offline

    EntityID

    I'm assuming you want to get net.minecraft.server.v1_8_R1.Block from org.bukkit.block.

    Code:
                        Block b = (...);
                        try {
                            Field field = ((CraftWorld) b.getWorld()).getHandle().getType(new BlockPosition(b.getX(), b.getY(), b.getZ())).getBlock().getClass().getDeclaredField("strength");
                            field.setAccessible(true);
                            field.setFloat(field, 50);
                        } catch (NoSuchFieldException | SecurityException e) {
                            e.printStackTrace();
                        }
    This might work. Even then it's probably not the most efficient way.
     
Thread Status:
Not open for further replies.

Share This Page