Setting block hardness not working

Started by Adam Albu on Fri, 07/23/2021 - 17:11

Topic category: Help with modding (Java Edition)

Last seen on 16:02, 14. Sep 2021
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Setting block hardness not working
Fri, 07/23/2021 - 17:11

I'm trying to alter a block's hardness with custom code, and I can't get it to work. Here is my code:

package net.mcreator.test.procedures;

import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.common.MinecraftForge;

import net.mcreator.test.Test2ModElements;

import java.util.Map;
import java.util.Collections;

@Test2ModElements.ModElement.Tag
public class TestProcedure extends Test2ModElements.ModElement {
    public TestProcedure(Test2ModElements instance) {
        super(instance, 2);
        MinecraftForge.EVENT_BUS.register(this);
        
    }

    public static void executeProcedure(Map<String, Object> dependencies) {
    Blocks.dirt.setHardness(1000.0F);
         Blocks.obsidian.setHardness(1.0F);
    }

    @Override
    public void init(FMLCommonSetupEvent event) {
        this.executeProcedure(Collections.emptyMap());
        
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
     Blocks.dirt.setHardness(1000.0F);
     Blocks.obsidian.setHardness(1.0F);
    }

}
 

I tried putting the .setHardnes() in all of the functions, nothing worked.