Increase Block Strength in NMS Code for 1.18.1

Discussion in 'Plugin Development' started by __FeelinFroggy, Apr 30, 2022.

  1. Offline


    I'm trying to build a plugin where i can increase the block strength of all iron blocks within my world( Server is on 1.18.1). I was able to get a ton of help from previous threads and discussions as to how to go abouts doing this, but I am still Stumbling upon some errors. Here is my code:

    import;import org.bukkit.Material;
    import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers;
    import java.lang.reflect.Field;
    public void onEnable() {
    // Plugin startup logic
    Material iron = Material.IRON_BLOCK;
    public void setBlockStrength(Material material, float strength) {
    try {
    Field field=Block.class.getDeclaredField("strength");
    field.setFloat(CraftMagicNumbers.getBlock(material), strength);
    } catch (NoSuchFieldException | IllegalAccessException exception) {
    The error says that when the getDeclaredField method is called, there is no field called "strength". The java class does not seem to have this parameter. Am I using the wrong block class?

    I have seen in various threads using
    import net.minecraft.server.v1_18_R0.1.Block instead of
    But I am unable to even import the net.minecraft.server.v1_18_R0.1 class (maybe because I didn't get my buildTools correct due to the upgrades after 1.17? But i checked this).

    Any thoughts as to how to get this error resolved would be greatly appreciated!


Share This Page