diff --git a/gradle.properties b/gradle.properties index 18473dc..22ba280 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version=1.20.6 - yarn_mappings=1.20.6+build.1 + minecraft_version=1.21-rc1 + yarn_mappings=1.21-rc1+build.1 loader_version=0.15.11 # Mod Properties - mod_version = 3.2.1 + mod_version = 3.2.2 maven_group = de.mschae23.minecraft.mod archives_base_name = grind-enchantments # Dependencies - fabric_api_version=0.98.0+1.20.6 + fabric_api_version=0.100.1+1.21 codec_config_api_version=2.0.0+1.20.5-rc3 tax_free_levels_version=loom-SNAPSHOT diff --git a/src/main/java/de/mschae23/grindenchantments/GrindEnchantmentsMod.java b/src/main/java/de/mschae23/grindenchantments/GrindEnchantmentsMod.java index 73f28f1..5da4295 100644 --- a/src/main/java/de/mschae23/grindenchantments/GrindEnchantmentsMod.java +++ b/src/main/java/de/mschae23/grindenchantments/GrindEnchantmentsMod.java @@ -107,6 +107,6 @@ public static void log(Level level, Object message) { } public static Identifier id(String path) { - return new Identifier(MODID, path); + return Identifier.of(MODID, path); } } diff --git a/src/main/java/de/mschae23/grindenchantments/config/FilterConfig.java b/src/main/java/de/mschae23/grindenchantments/config/FilterConfig.java index 5222b17..d5132b7 100644 --- a/src/main/java/de/mschae23/grindenchantments/config/FilterConfig.java +++ b/src/main/java/de/mschae23/grindenchantments/config/FilterConfig.java @@ -26,6 +26,7 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntryList; +import net.minecraft.registry.tag.EnchantmentTags; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -48,7 +49,7 @@ public ItemEnchantmentsComponent filter(ItemEnchantmentsComponent enchantments) if (this.curses == FilterAction.DENY) { for (RegistryEntry entry : builder.getEnchantments()) { - if (entry.value().isCursed()) { + if (entry.isIn(EnchantmentTags.CURSE)) { return ItemEnchantmentsComponent.DEFAULT; } } @@ -63,7 +64,7 @@ public ItemEnchantmentsComponent filter(ItemEnchantmentsComponent enchantments) } builder.remove(enchantment -> - ((this.curses == FilterAction.IGNORE) && enchantment.value().isCursed()) + ((this.curses == FilterAction.IGNORE) && enchantment.isIn(EnchantmentTags.CURSE)) || ((this.enchantment.action == FilterAction.IGNORE) == this.enchantment.enchantments.contains(enchantment))); return builder.build(); @@ -78,7 +79,7 @@ public ItemEnchantmentsComponent filterReversed(ItemEnchantmentsComponent enchan if (this.curses == FilterAction.DENY) { for (RegistryEntry entry : builder.getEnchantments()) { - if (entry.value().isCursed()) { + if (entry.isIn(EnchantmentTags.CURSE)) { return ItemEnchantmentsComponent.DEFAULT; } } @@ -93,7 +94,7 @@ public ItemEnchantmentsComponent filterReversed(ItemEnchantmentsComponent enchan } builder.remove(enchantment -> - ((this.curses == FilterAction.ALLOW) || !enchantment.value().isCursed()) + ((this.curses == FilterAction.ALLOW) || !enchantment.isIn(EnchantmentTags.CURSE)) && ((this.enchantment.action == FilterAction.ALLOW) == this.enchantment.enchantments.contains(enchantment))); return builder.build(); diff --git a/src/main/java/de/mschae23/grindenchantments/cost/CountLevelsCostFunction.java b/src/main/java/de/mschae23/grindenchantments/cost/CountLevelsCostFunction.java index 2966a5b..a8fcec6 100644 --- a/src/main/java/de/mschae23/grindenchantments/cost/CountLevelsCostFunction.java +++ b/src/main/java/de/mschae23/grindenchantments/cost/CountLevelsCostFunction.java @@ -21,6 +21,7 @@ import net.minecraft.component.type.ItemEnchantmentsComponent; import net.minecraft.registry.RegistryWrapper; +import net.minecraft.registry.tag.EnchantmentTags; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -34,8 +35,8 @@ public record CountLevelsCostFunction(double normalFactor, double treasureFactor @Override public double getCost(ItemEnchantmentsComponent enchantments, FilterConfig filter, RegistryWrapper.WrapperLookup wrapperLookup) { - return enchantments.getEnchantmentsMap().stream() - .mapToDouble(entry -> (double) entry.getIntValue() * (entry.getKey().value().isTreasure() ? this.treasureFactor : this.normalFactor)) + return enchantments.getEnchantmentEntries().stream() + .mapToDouble(entry -> (double) entry.getIntValue() * (entry.getKey().isIn(EnchantmentTags.TREASURE) ? this.treasureFactor : this.normalFactor)) .sum(); } diff --git a/src/main/java/de/mschae23/grindenchantments/cost/CountMinPowerCostFunction.java b/src/main/java/de/mschae23/grindenchantments/cost/CountMinPowerCostFunction.java index e7c2069..352f3dd 100644 --- a/src/main/java/de/mschae23/grindenchantments/cost/CountMinPowerCostFunction.java +++ b/src/main/java/de/mschae23/grindenchantments/cost/CountMinPowerCostFunction.java @@ -30,7 +30,7 @@ public class CountMinPowerCostFunction implements CostFunction { @Override public double getCost(ItemEnchantmentsComponent enchantments, FilterConfig filter, RegistryWrapper.WrapperLookup wrapperLookup) { - return enchantments.getEnchantmentsMap().stream() + return enchantments.getEnchantmentEntries().stream() .mapToDouble(entry -> entry.getKey().value().getMinPower(entry.getIntValue())) .sum(); } diff --git a/src/main/java/de/mschae23/grindenchantments/cost/FirstEnchantmentCostFunction.java b/src/main/java/de/mschae23/grindenchantments/cost/FirstEnchantmentCostFunction.java index 8865811..d012230 100644 --- a/src/main/java/de/mschae23/grindenchantments/cost/FirstEnchantmentCostFunction.java +++ b/src/main/java/de/mschae23/grindenchantments/cost/FirstEnchantmentCostFunction.java @@ -42,7 +42,7 @@ public double getCost(ItemEnchantmentsComponent enchantments, FilterConfig filte return 1.0; } else { ItemEnchantmentsComponent.Builder builder = new ItemEnchantmentsComponent.Builder(ItemEnchantmentsComponent.DEFAULT); - builder.add(firstEnchantment.left().value(), firstEnchantment.rightInt()); + builder.add(firstEnchantment.left(), firstEnchantment.rightInt()); return this.delegate.getCost(builder.build(), filter, wrapperLookup); } diff --git a/src/main/java/de/mschae23/grindenchantments/impl/MoveOperation.java b/src/main/java/de/mschae23/grindenchantments/impl/MoveOperation.java index 37c1728..3445760 100644 --- a/src/main/java/de/mschae23/grindenchantments/impl/MoveOperation.java +++ b/src/main/java/de/mschae23/grindenchantments/impl/MoveOperation.java @@ -74,7 +74,7 @@ public boolean canInsert(ItemStack stack, ItemStack other, int slotId) { ItemStack result = input2.copy(); ItemEnchantmentsComponent.Builder builder = new ItemEnchantmentsComponent.Builder(result.getOrDefault(DataComponentTypes.STORED_ENCHANTMENTS, ItemEnchantmentsComponent.DEFAULT)); - int targetLevel = builder.getLevel(firstEnchantment.left().value()); + int targetLevel = builder.getLevel(firstEnchantment.left()); if (targetLevel > 0) { if (targetLevel != firstEnchantment.rightInt() || firstEnchantment.rightInt() == firstEnchantment.left().value().getMaxLevel()) { @@ -86,7 +86,7 @@ public boolean canInsert(ItemStack stack, ItemStack other, int slotId) { targetLevel = firstEnchantment.rightInt(); } - builder.add(firstEnchantment.left().value(), targetLevel); + builder.add(firstEnchantment.left(), targetLevel); if (result.getItem() == Items.BOOK) { result = result.copyComponentsToNewStack(Items.ENCHANTED_BOOK, 1); @@ -201,7 +201,7 @@ public static ObjectIntPair> getFirstEnchantment(Item } } - for (Object2IntMap.Entry> entry : enchantments.getEnchantmentsMap()) { + for (Object2IntMap.Entry> entry : enchantments.getEnchantmentEntries()) { if (firstEnchantment == null && !tooltipOrder.contains(entry.getKey())) { firstEnchantment = ObjectIntPair.of(entry.getKey(), entry.getIntValue()); break; diff --git a/src/main/resources/grindenchantments.accesswidener b/src/main/resources/grindenchantments.accesswidener index dd2b009..925759b 100644 --- a/src/main/resources/grindenchantments.accesswidener +++ b/src/main/resources/grindenchantments.accesswidener @@ -4,4 +4,4 @@ accessible field net/minecraft/screen/GrindstoneScreenHandler result Lnet/minecr accessible field net/minecraft/component/type/ItemEnchantmentsComponent enchantments Lit/unimi/dsi/fastutil/objects/Object2IntOpenHashMap; accessible method net/minecraft/component/type/ItemEnchantmentsComponent getTooltipOrderList (Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/registry/tag/TagKey;)Lnet/minecraft/registry/entry/RegistryEntryList; -accessible method net/minecraft/enchantment/EnchantmentHelper getEnchantmentsComponentType (Lnet/minecraft/item/ItemStack;)Lnet/minecraft/component/DataComponentType; +accessible method net/minecraft/enchantment/EnchantmentHelper getEnchantmentsComponentType (Lnet/minecraft/item/ItemStack;)Lnet/minecraft/component/ComponentType;