Block Hardness

Discussion in 'Plugin Development' started by AlbkadDev, Jul 24, 2017.

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

    AlbkadDev

    So basically I just played around with some code that I found and it gives me no errors but doesnt seem to work. What it does is that it sets the hardness of the block. It doesnt seem to work though. Any other code that does the same would be appriciated. Quite new to NMS and that kind of stuff.
    Code:
    import java.lang.reflect.Field;
    import java.util.Iterator;
    import java.util.Random;
    
    import org.bukkit.Bukkit;
    import org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import net.minecraft.server.v1_8_R1.Block;
    import net.minecraft.server.v1_8_R1.BlockStone;
    import net.minecraft.server.v1_8_R1.Material;
    
    
    public class Main extends JavaPlugin {
       
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(new EventListener(this), this);
            try {
                Field field=net.minecraft.server.v1_8_R1.Block.class.getDeclaredField("strength");
                field.setAccessible(true);
                try {
                    field.set(net.minecraft.server.v1_8_R1.Block.getById(1), 50.0F);
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    e.printStackTrace();
                }
            } catch (NoSuchFieldException | SecurityException e) {
                e.printStackTrace();
            }
           
        }
       
    }
     
  2. Offline

    mehboss

    Doesn't hurt to take a second and google it.. I literally showed someone this that had the same question.. Here is a link I showed them: https://bukkit.org/threads/increase-block-resistance-strength.66304/
     
  3. Offline

    AlbkadDev

    @mehboss I cant seem to get this to work because it seems to be a little outdated and the stuff isnt working anymore. To my knowledge atleast. This seems like something I gotto test around with. :confused:
     
Thread Status:
Not open for further replies.

Share This Page