While I was creating a mod, I noticed that my mod's blocks harvest levels were all being set to zero, despite me defining them in the block's properties.
So I did a clean install of the latest MDK (Forge 1.16.1-32.0.39), and made a quick test just to see if something else was causing it, but I haven't been able to figure out what's making this happen yet.
Here's what the code from my testing looks like:
@Mod("examplemod")
public class ExampleMod
{
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "examplemod");
public static final RegistryObject<Block> HARD_BLOCK = BLOCKS.register("coolblockname", () -> new Block(
Block.Properties.create(Material.ROCK)
.harvestLevel(3)
.harvestTool(ToolType.PICKAXE)
.hardnessAndResistance(2.5F, 10F)
));
public ExampleMod() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(bus);
MinecraftForge.EVENT_BUS.register(this);
}
}
This is what the loot table for the block looks like:
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:carrot"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
Lastly, here's a quick video of me showing that the block does still drop in game (despite the wrong mining level/tool)
If there's anything else that I can include to help diagnose the issue please let me know! Thanks