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,9 +14,10 @@
"term": {
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
"sub_predicates": {
"minecraft:enchantments": [
{
"enchantment": "minecraft:silk_touch",
"enchantments": "minecraft:silk_touch",
"levels": {
"min": 1
}
@@ -25,6 +26,7 @@
}
}
}
}
],
"functions": [
{
@@ -48,15 +50,16 @@
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:coal_ore",
"name": "custom_ore_gen:concentratedcoalore",
"weight": 1,
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
"sub_predicates": {
"minecraft:enchantments": [
{
"enchantment": "minecraft:silk_touch",
"enchantments": "minecraft:silk_touch",
"levels": {
"min": 1
}
@@ -64,6 +67,7 @@
]
}
}
}
],
"functions": [
{