diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f3368..40d7499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 87.0.0 + +### Changed + +- Updated to 1.21 + + ## 85.0.0 ### Changed diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/items/EnchantCommand.java b/common/src/main/java/com/sunekaer/toolkit/commands/items/EnchantCommand.java index 999172c..6f0964f 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/items/EnchantCommand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/items/EnchantCommand.java @@ -54,12 +54,12 @@ private static int enchant(CommandContext context, Holder.Re throw ERROR_MISSING_PLAYER.create(); } - if (!enchantment.canEnchant(mainHandItem) || !EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(mainHandItem).keySet(), enchantment)) { + if (!enchantment.canEnchant(mainHandItem) || !EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(mainHandItem).keySet(), arg2)) { throw ERROR_INCOMPATIBLE.create(mainHandItem.getItem().getName(mainHandItem).getString()); } - EnchantmentHacks.enchantItem(mainHandItem, enchantment, (short) level); - source.sendSuccess(() -> Component.translatable("commands.toolkit.enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(level).getString()), false); + EnchantmentHacks.enchantItem(mainHandItem, arg2, (short) level); + source.sendSuccess(() -> Component.translatable("commands.toolkit.enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), Enchantment.getFullname(arg2, level).getString()), false); return 1; } @@ -74,17 +74,17 @@ private static int removeEnchantment(CommandContext context, Enchantment enchantment = arg2.value(); var enchantments = EnchantmentHelper.getEnchantmentsForCrafting(mainHandItem); - var hasEnchantment = enchantments.getLevel(enchantment) > 0; + var hasEnchantment = enchantments.getLevel(arg2) > 0; if (!hasEnchantment) { - throw ERROR_MISSING_ENCHANTMENT.create(mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1)); + throw ERROR_MISSING_ENCHANTMENT.create(mainHandItem.getItem().getName(mainHandItem).getString(), Enchantment.getFullname(arg2, 1)); } - boolean success = EnchantmentHacks.removeEnchantment(mainHandItem, enchantment); + boolean success = EnchantmentHacks.removeEnchantment(mainHandItem, arg2); if (success) { - source.sendSuccess(() -> Component.translatable("commands.toolkit.remove_enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1).getString()), false); + source.sendSuccess(() -> Component.translatable("commands.toolkit.remove_enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), Enchantment.getFullname(arg2, 1).getString()), false); } else { - source.sendFailure(Component.translatable("commands.toolkit.remove_enchant.failed", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1).getString())); + source.sendFailure(Component.translatable("commands.toolkit.remove_enchant.failed", mainHandItem.getItem().getName(mainHandItem).getString(), Enchantment.getFullname(arg2, 1).getString())); } return success ? 1 : 0; } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/items/SlayerCommand.java b/common/src/main/java/com/sunekaer/toolkit/commands/items/SlayerCommand.java index fd6aba8..aa7a240 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/items/SlayerCommand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/items/SlayerCommand.java @@ -3,12 +3,15 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; +import net.minecraft.core.Registry; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.ItemEnchantments; @@ -35,7 +38,8 @@ private static int giveItem(ServerPlayer player) { var enchants = itemstack.get(DataComponents.ENCHANTMENTS); var mutableEnchants = new ItemEnchantments.Mutable(enchants); - enchantments.forEach(e -> mutableEnchants.set(e, Short.MAX_VALUE)); + Registry enchantmentRegistry = player.server.registryAccess().registryOrThrow(Registries.ENCHANTMENT); + enchantments.forEach(e -> mutableEnchants.set(enchantmentRegistry.getHolderOrThrow(e), Short.MAX_VALUE)); itemstack.set(DataComponents.ENCHANTMENTS, mutableEnchants.toImmutable()); boolean added = player.getInventory().add(itemstack.copy()); diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/level/ClearCommand.java b/common/src/main/java/com/sunekaer/toolkit/commands/level/ClearCommand.java index 06601e2..a7882cb 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/level/ClearCommand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/level/ClearCommand.java @@ -56,7 +56,7 @@ private static int remove(CommandSourceStack source, int size, String filter) th var removalCheck = RemovalPredicate.getFromName(filter).orElse(RemovalPredicate.JUST_ORES); Predicate customCheck = null; if (filter.startsWith("#")) { - customCheck = state -> state.is(TagKey.create(Registries.BLOCK, new ResourceLocation(filter.replace("#", "")))); + customCheck = state -> state.is(TagKey.create(Registries.BLOCK, ResourceLocation.withDefaultNamespace(filter.replace("#", "")))); } else if(filter.contains(":")) { customCheck = state -> BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString().equalsIgnoreCase(filter); } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/level/MineAreaCommand.java b/common/src/main/java/com/sunekaer/toolkit/commands/level/MineAreaCommand.java index e8ea790..4d2848a 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/level/MineAreaCommand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/level/MineAreaCommand.java @@ -10,6 +10,8 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -21,6 +23,7 @@ import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.SmeltingRecipe; +import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -49,8 +52,10 @@ public class MineAreaCommand { private static int mine(CommandSourceStack source, int size, String filter) throws CommandSyntaxException { try { ItemStack breaker = new ItemStack(Items.NETHERITE_PICKAXE); + + Registry enchantmentRegistry = source.getLevel().registryAccess().registryOrThrow(Registries.ENCHANTMENT); // breaker.enchant(Enchantments.BLOCK_FORTUNE, 3); - breaker.enchant(Enchantments.SILK_TOUCH, 1); + breaker.enchant(enchantmentRegistry.getHolderOrThrow(Enchantments.SILK_TOUCH), 1); MinecraftServer server = source.getServer(); ServerLevel level = source.getLevel(); diff --git a/common/src/main/java/com/sunekaer/toolkit/network/Handler.java b/common/src/main/java/com/sunekaer/toolkit/network/Handler.java index f322a2b..f13072b 100644 --- a/common/src/main/java/com/sunekaer/toolkit/network/Handler.java +++ b/common/src/main/java/com/sunekaer/toolkit/network/Handler.java @@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceLocation; public class Handler { - public static final NetworkChannel CHANNEL = NetworkChannel.create(new ResourceLocation(Toolkit.MOD_ID, "networking_channel")); + public static final NetworkChannel CHANNEL = NetworkChannel.create(ResourceLocation.fromNamespaceAndPath(Toolkit.MOD_ID, "networking_channel")); public static void init() { CHANNEL.register(SetCopy.class, SetCopy::encode, SetCopy::new, SetCopy::apply); diff --git a/common/src/main/java/com/sunekaer/toolkit/utils/EnchantmentHacks.java b/common/src/main/java/com/sunekaer/toolkit/utils/EnchantmentHacks.java index 7f5f2d2..5dff132 100644 --- a/common/src/main/java/com/sunekaer/toolkit/utils/EnchantmentHacks.java +++ b/common/src/main/java/com/sunekaer/toolkit/utils/EnchantmentHacks.java @@ -9,7 +9,7 @@ import java.util.Objects; public class EnchantmentHacks { - public static void enchantItem(ItemStack stack, Enchantment enchantment, short level) { + public static void enchantItem(ItemStack stack, Holder.Reference enchantment, short level) { var enchantments = stack.get(DataComponents.ENCHANTMENTS); var mutableEnchants = new ItemEnchantments.Mutable(Objects.requireNonNullElse(enchantments, ItemEnchantments.EMPTY)); @@ -17,7 +17,7 @@ public static void enchantItem(ItemStack stack, Enchantment enchantment, short l stack.set(DataComponents.ENCHANTMENTS, mutableEnchants.toImmutable()); } - public static boolean removeEnchantment(ItemStack stack, Enchantment enchantment) { + public static boolean removeEnchantment(ItemStack stack, Holder.Reference enchantment) { var enchantments = stack.get(DataComponents.ENCHANTMENTS); if (enchantments == null) { return false; @@ -25,7 +25,7 @@ public static boolean removeEnchantment(ItemStack stack, Enchantment enchantment var mutableEnchants = new ItemEnchantments.Mutable(enchantments); for (Holder enchant : mutableEnchants.keySet()) { - if (enchant.value().equals(enchantment)) { + if (enchant.value().equals(enchantment.value())) { mutableEnchants.set(enchantment, 0); stack.set(DataComponents.ENCHANTMENTS, mutableEnchants.toImmutable()); return true; diff --git a/fabric/src/main/java/com/sunekaer/toolkit/fabric/ToolkitFabric.java b/fabric/src/main/java/com/sunekaer/toolkit/fabric/ToolkitFabric.java index b4eadc1..f2a3098 100644 --- a/fabric/src/main/java/com/sunekaer/toolkit/fabric/ToolkitFabric.java +++ b/fabric/src/main/java/com/sunekaer/toolkit/fabric/ToolkitFabric.java @@ -12,7 +12,7 @@ public class ToolkitFabric implements ModInitializer { public void onInitialize() { Toolkit.init(); ArgumentTypeRegistry.registerArgumentType( - new ResourceLocation(Toolkit.MOD_ID, "kill_type"), + ResourceLocation.fromNamespaceAndPath(Toolkit.MOD_ID, "kill_type"), KillEntitiesCommand.KillTypeArgument.class, SingletonArgumentInfo.contextFree(KillEntitiesCommand.KillTypeArgument::killType) ); diff --git a/gradle.properties b/gradle.properties index b0dc3de..046a6c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,23 @@ org.gradle.jvmargs=-Xmx2048M -minecraft_version=1.20.6 +minecraft_version=1.21 #enabled_platforms=fabric,forge,neoforge enabled_platforms=fabric,neoforge archives_base_name=ToolKit -mod_version=86.0.0 +mod_version=87.0.0 maven_group=com.sunekaer.mods -architectury_version=12.0.28 +architectury_version=13.0.1 fabric_loader_version=0.15.11 -fabric_api_version=0.98.0+1.20.6 +fabric_api_version=0.100.3+1.21 forge_version=50.0.9 forge_gradle_version=6.0.20 -neoforge_version=20.6.48-beta -neoforge_gradle_version=7.0.83 +neoforge_version=21.0.19-beta +neoforge_gradle_version=7.0.145 curseforge_id=324888 modrinth_id=fWj0tJp5 diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 5cfc086..cdb441b 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion="[2,)" #mandatory +loaderVersion="[4,)" #mandatory license = "All Rights Reserved" [[mods]] @@ -14,20 +14,20 @@ This mod adds bunch of useful commands [[dependencies.toolkit]] modId = "neoforge" required = true -versionRange = "[20.5,)" +versionRange = "[21,)" ordering = "NONE" side = "BOTH" [[dependencies.toolkit]] modId = "minecraft" required = true -versionRange = "[1.20.5,)" +versionRange = "[1.21,)" ordering = "NONE" side = "BOTH" [[dependencies.toolkit]] modId = "architectury" required = true -versionRange = "[12.0.28,)" +versionRange = "[13.0.1,)" ordering = "AFTER" side = "BOTH"