Fix custom ore drops and tool enchantability for 1.21

This commit is contained in:
feldenr
2026-02-02 22:24:52 +01:00
parent b636fd4295
commit 4b9a4b0a05
2 changed files with 48 additions and 16 deletions
@@ -0,0 +1,28 @@
package net.mcreator.customoregen.event;
import net.mcreator.customoregen.CustomOreGenMod;
import net.mcreator.customoregen.init.CustomOreGenModItems;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.enchantment.Enchantable;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.event.ModifyDefaultComponentsEvent;
@Mod.EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class EnchantabilityFix {
@SubscribeEvent
public static void modifyComponents(ModifyDefaultComponentsEvent event) {
// Tools - Value 9
event.modify(CustomOreGenModItems.SHARDDIAMONDPICKAXE.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(9)));
event.modify(CustomOreGenModItems.SHARDDIAMONDSHOVEL.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(9)));
event.modify(CustomOreGenModItems.SHARDDIAMONDAXE.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(9)));
event.modify(CustomOreGenModItems.SHARDDIAMONDPAXEL.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(9)));
// Armor - Value 14
event.modify(CustomOreGenModItems.SHARDDIAMONDHELMET.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(14)));
event.modify(CustomOreGenModItems.SHARDDIAMONDCHESTPLATE.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(14)));
event.modify(CustomOreGenModItems.SHARDDIAMONDLEGGINGS.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(14)));
event.modify(CustomOreGenModItems.SHARDDIAMONDBOOTS.get(), builder -> builder.set(DataComponents.ENCHANTABLE, new Enchantable(14)));
}
}
@@ -14,14 +14,16 @@
"term": { "term": {
"condition": "minecraft:match_tool", "condition": "minecraft:match_tool",
"predicate": { "predicate": {
"enchantments": [ "sub_predicates": {
{ "minecraft:enchantments": [
"enchantment": "minecraft:silk_touch", {
"levels": { "enchantments": "minecraft:silk_touch",
"min": 1 "levels": {
"min": 1
}
} }
} ]
] }
} }
} }
} }
@@ -48,20 +50,22 @@
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
"name": "minecraft:coal_ore", "name": "custom_ore_gen:concentratedcoalore",
"weight": 1, "weight": 1,
"conditions": [ "conditions": [
{ {
"condition": "minecraft:match_tool", "condition": "minecraft:match_tool",
"predicate": { "predicate": {
"enchantments": [ "sub_predicates": {
{ "minecraft:enchantments": [
"enchantment": "minecraft:silk_touch", {
"levels": { "enchantments": "minecraft:silk_touch",
"min": 1 "levels": {
"min": 1
}
} }
} ]
] }
} }
} }
], ],