|
39 | 39 | import java.util.function.Predicate; |
40 | 40 | import java.util.function.ToIntFunction; |
41 | 41 |
|
42 | | -import dev.jorel.commandapi.*; |
43 | 42 | import org.bukkit.Bukkit; |
44 | 43 | import org.bukkit.Color; |
45 | 44 | import org.bukkit.Location; |
|
90 | 89 | import com.mojang.serialization.Codec; |
91 | 90 | import com.mojang.serialization.DataResult; |
92 | 91 |
|
| 92 | +import dev.jorel.commandapi.CommandAPI; |
| 93 | +import dev.jorel.commandapi.CommandAPIHandler; |
| 94 | +import dev.jorel.commandapi.CommandRegistrationStrategy; |
| 95 | +import dev.jorel.commandapi.PaperCommandRegistration; |
| 96 | +import dev.jorel.commandapi.SafeVarHandle; |
| 97 | +import dev.jorel.commandapi.SpigotCommandRegistration; |
93 | 98 | import dev.jorel.commandapi.arguments.ArgumentSubType; |
94 | 99 | import dev.jorel.commandapi.arguments.SuggestionProviders; |
95 | 100 | import dev.jorel.commandapi.commandsenders.AbstractCommandSender; |
|
146 | 151 | import net.minecraft.commands.functions.InstantiatedFunction; |
147 | 152 | import net.minecraft.commands.synchronization.ArgumentUtils; |
148 | 153 | import net.minecraft.core.BlockPos; |
149 | | -import net.minecraft.core.component.DataComponentMap; |
150 | | -import net.minecraft.core.component.PatchedDataComponentMap; |
151 | 154 | import net.minecraft.core.particles.BlockParticleOption; |
152 | 155 | import net.minecraft.core.particles.ColorParticleOption; |
153 | 156 | import net.minecraft.core.particles.DustColorTransitionOptions; |
@@ -304,9 +307,9 @@ public String[] compatibleVersions() { |
304 | 307 | return new String[] { "1.21" }; |
305 | 308 | }; |
306 | 309 |
|
| 310 | + @Differs(from = "1.20.6", by = "ItemInput constructor uses a data components patch, instead of a data components map") |
307 | 311 | private static String serializeNMSItemStack(ItemStack is) { |
308 | | - final DataComponentMap patchedMap = PatchedDataComponentMap.fromPatch(PatchedDataComponentMap.EMPTY, is.getComponentsPatch()); |
309 | | - return new ItemInput(is.getItemHolder(), patchedMap).serialize(COMMAND_BUILD_CONTEXT); |
| 312 | + return new ItemInput(is.getItemHolder(), is.getComponentsPatch()).serialize(COMMAND_BUILD_CONTEXT); |
310 | 313 | } |
311 | 314 |
|
312 | 315 | @Override |
@@ -474,8 +477,9 @@ public final World getDimension(CommandContext<CommandSourceStack> cmdCtx, Strin |
474 | 477 | @Override |
475 | 478 | public final Enchantment getEnchantment(CommandContext<CommandSourceStack> cmdCtx, String key) |
476 | 479 | throws CommandSyntaxException { |
477 | | - return Registry.ENCHANTMENT.get(fromResourceLocation( |
478 | | - BuiltInRegistries.ENCHANTMENT.getKey(ResourceArgument.getEnchantment(cmdCtx, key).value()))); |
| 480 | + final net.minecraft.world.item.enchantment.Enchantment enchantment = ResourceArgument.getEnchantment(cmdCtx, key).value(); |
| 481 | + final ResourceLocation resource = this.<MinecraftServer>getMinecraftServer().registryAccess().registryOrThrow(Registries.ENCHANTMENT).getKey(enchantment); |
| 482 | + return Registry.ENCHANTMENT.get(fromResourceLocation(resource)); |
479 | 483 | } |
480 | 484 |
|
481 | 485 | @Override |
@@ -570,9 +574,10 @@ public final FunctionWrapper[] getFunction(CommandContext<CommandSourceStack> cm |
570 | 574 | return result.toArray(new FunctionWrapper[0]); |
571 | 575 | } |
572 | 576 |
|
| 577 | + @Differs(from = "1.20.6", by = "ResourceLocation constructor change to static ResourceLocation#fromNamespaceAndPath") |
573 | 578 | @Override |
574 | 579 | public SimpleFunctionWrapper getFunction(NamespacedKey key) { |
575 | | - final ResourceLocation resourceLocation = new ResourceLocation(key.getNamespace(), key.getKey()); |
| 580 | + final ResourceLocation resourceLocation = ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getKey()); |
576 | 581 | Optional<CommandFunction<CommandSourceStack>> commandFunctionOptional = this |
577 | 582 | .<MinecraftServer>getMinecraftServer().getFunctions().get(resourceLocation); |
578 | 583 | if (commandFunctionOptional.isPresent()) { |
@@ -862,9 +867,10 @@ public SuggestionProvider<CommandSourceStack> getSuggestionProvider(SuggestionPr |
862 | 867 | }; |
863 | 868 | } |
864 | 869 |
|
| 870 | + @Differs(from = "1.20.6", by = "ResourceLocation constructor change to static ResourceLocation#fromNamespaceAndPath") |
865 | 871 | @Override |
866 | 872 | public final SimpleFunctionWrapper[] getTag(NamespacedKey key) { |
867 | | - Collection<CommandFunction<CommandSourceStack>> customFunctions = this.<MinecraftServer>getMinecraftServer().getFunctions().getTag(new ResourceLocation(key.getNamespace(), key.getKey())); |
| 873 | + Collection<CommandFunction<CommandSourceStack>> customFunctions = this.<MinecraftServer>getMinecraftServer().getFunctions().getTag(ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getKey())); |
868 | 874 | SimpleFunctionWrapper[] convertedCustomFunctions = new SimpleFunctionWrapper[customFunctions.size()]; |
869 | 875 | int index = 0; |
870 | 876 | for (CommandFunction<CommandSourceStack> customFunction : customFunctions) { |
|
0 commit comments