Skip to content

Commit c7ebcc0

Browse files
authored
Merge pull request #206 from KyoriPowered/dev/1.21.6
Minecraft 1.21.6
2 parents 1426134 + fa55fcd commit c7ebcc0

File tree

13 files changed

+55
-110
lines changed

13 files changed

+55
-110
lines changed

fabric/src/main/java/net/kyori/adventure/platform/fabric/impl/ServerArgumentTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2022-2024 KyoriPowered
4+
* Copyright (c) 2022-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -102,7 +102,7 @@ public static void knownArgumentTypes(final ServerPlayer player, final Set<Resou
102102
((ServerPlayerBridge) player).bridge$knownArguments(ids);
103103
sendMappings(player, responder);
104104
if (!ids.isEmpty()) { // TODO: Avoid resending the whole command tree, find a way to receive the packet before sending?
105-
player.server.getCommands().sendCommands(player);
105+
player.getServer().getCommands().sendCommands(player);
106106
}
107107
}
108108

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2022-2024 KyoriPowered
4+
* Copyright (c) 2022-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -24,14 +24,14 @@
2424
package net.kyori.adventure.platform.fabric.impl.mixin.minecraft.commands;
2525

2626
import com.google.common.collect.Iterators;
27+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
28+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
29+
import com.llamalad7.mixinextras.sugar.Local;
2730
import com.mojang.brigadier.arguments.ArgumentType;
2831
import com.mojang.brigadier.builder.ArgumentBuilder;
2932
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
30-
import com.mojang.brigadier.exceptions.CommandSyntaxException;
31-
import com.mojang.brigadier.suggestion.SuggestionProvider;
3233
import com.mojang.brigadier.tree.CommandNode;
3334
import java.util.Iterator;
34-
import java.util.Map;
3535
import java.util.Set;
3636
import net.kyori.adventure.platform.fabric.impl.ServerArgumentType;
3737
import net.kyori.adventure.platform.fabric.impl.ServerArgumentTypes;
@@ -40,36 +40,32 @@
4040
import net.minecraft.commands.CommandBuildContext;
4141
import net.minecraft.commands.CommandSourceStack;
4242
import net.minecraft.commands.Commands;
43-
import net.minecraft.commands.SharedSuggestionProvider;
4443
import net.minecraft.resources.ResourceLocation;
4544
import org.spongepowered.asm.mixin.Mixin;
4645
import org.spongepowered.asm.mixin.injection.At;
47-
import org.spongepowered.asm.mixin.injection.Inject;
4846
import org.spongepowered.asm.mixin.injection.ModifyVariable;
49-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
50-
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
5147

5248
@Mixin(Commands.class)
5349
public abstract class CommandsMixin {
5450

5551
@SuppressWarnings({"rawtypes", "unchecked"}) // argument type generics
56-
@Inject(
52+
@WrapOperation(
5753
method = "fillUsableCommands",
58-
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
59-
at = @At(value = "INVOKE", target = "com.mojang.brigadier.builder.RequiredArgumentBuilder.getSuggestionsProvider()Lcom/mojang/brigadier/suggestion/SuggestionProvider;", remap = false, ordinal = 0)
60-
/*slice = @Slice(from = @At(value = "INVOKE_ASSIGN", target = "RequiredArgumentBuilder.executes(Lcom/mojang/brigadier/Command;)Lcom/mojang/brigadier/builder/ArgumentBuilder;", remap = false), to = @At(value = "INVOKE", target = "RequiredArgumentBuilder.getRedirect()Lcom/mojang/brigadier/tree/CommandNode;", remap = false))*/
54+
at = @At(
55+
value = "INVOKE",
56+
target = "Lcom/mojang/brigadier/builder/ArgumentBuilder;build()Lcom/mojang/brigadier/tree/CommandNode;",
57+
remap = false
58+
)
6159
)
62-
public <T> void adventure$replaceArgumentType(
63-
final CommandNode<CommandSourceStack> tree,
64-
final CommandNode<SharedSuggestionProvider> result,
65-
final CommandSourceStack source,
66-
final Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> nodes,
67-
final CallbackInfo ci,
68-
final Iterator<?> it,
69-
final CommandNode<CommandSourceStack> current,
70-
final ArgumentBuilder<?, ?> unused,
71-
final RequiredArgumentBuilder<?, T> builder
72-
) throws CommandSyntaxException {
60+
private static <T> CommandNode<T> adventure$replaceArgumentType(
61+
final ArgumentBuilder<T, ?> instance,
62+
final Operation<CommandNode<T>> original,
63+
final @Local(argsOnly = true) T sourceRaw
64+
) {
65+
if (!(instance instanceof RequiredArgumentBuilder builder)) {
66+
return original.call(instance); // only replace argument types for required arguments
67+
}
68+
final CommandSourceStack source = (CommandSourceStack) sourceRaw;
7369
ServerArgumentType<ArgumentType<T>> type = ServerArgumentTypes.byClass((Class) builder.getType().getClass());
7470
final Set<ResourceLocation> knownExtraCommands = ServerArgumentTypes.knownArgumentTypes(source.getPlayer()); // throws an exception, we can ignore bc this is always a player
7571
// If we have a replacement and the arg type isn't known to the client, change the argument type
@@ -79,11 +75,11 @@ public abstract class CommandsMixin {
7975
final CommandBuildContext ctx = CommandBuildContext.simple(source.registryAccess(), source.enabledFeatures());
8076
((RequiredArgumentBuilderAccess) builder).accessor$type(type.fallbackProvider().apply(builder.getType(), ctx));
8177
if (type.fallbackSuggestions() != null) {
82-
builder.suggests((SuggestionProvider) type.fallbackSuggestions());
78+
builder.suggests(type.fallbackSuggestions());
8379
}
8480
type = ServerArgumentTypes.byClass((Class) builder.getType().getClass());
8581
}
86-
82+
return original.call(instance);
8783
}
8884

8985
/**
@@ -95,7 +91,7 @@ public abstract class CommandsMixin {
9591
* @return the filtered iterator
9692
*/
9793
@ModifyVariable(method = "fillUsableCommands", at = @At("STORE"), ordinal = 0, require = 0)
98-
private Iterator<CommandNode<CommandSourceStack>> adventure$filterHiddenCommands(final Iterator<CommandNode<CommandSourceStack>> itr) {
94+
private static Iterator<CommandNode<CommandSourceStack>> adventure$filterHiddenCommands(final Iterator<CommandNode<CommandSourceStack>> itr) {
9995
return Iterators.filter(itr, node -> !(node.getRequirement() instanceof HiddenRequirement<CommandSourceStack>));
10096
}
10197
}

fabric/src/test/java/net/kyori/adventure/platform/fabric/ComponentConversionTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2023-2024 KyoriPowered
4+
* Copyright (c) 2023-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,7 @@
2525

2626
import com.google.gson.JsonElement;
2727
import com.google.gson.stream.JsonWriter;
28+
import com.mojang.serialization.JsonOps;
2829
import java.io.IOException;
2930
import java.io.StringWriter;
3031
import java.lang.annotation.ElementType;
@@ -48,6 +49,7 @@
4849
import net.kyori.adventure.translation.GlobalTranslator;
4950
import net.minecraft.core.component.DataComponentPatch;
5051
import net.minecraft.core.component.DataComponents;
52+
import net.minecraft.network.chat.ComponentSerialization;
5153
import net.minecraft.util.GsonHelper;
5254
import net.minecraft.world.item.ItemStack;
5355
import net.minecraft.world.item.Items;
@@ -91,7 +93,9 @@ void testComponentEqualSerializationWrapped(final Component input) {
9193
@TestOnComponents
9294
void testNonWrappingSerializerComponentsEqual(final Component input) {
9395
final JsonElement serialized = GsonComponentSerializer.gson().serializeToTree(input);
94-
final JsonElement serializedNative = this.componentToJson(net.minecraft.network.chat.Component.Serializer.fromJson(serialized, lookup()));
96+
final JsonElement serializedNative = this.componentToJson(
97+
ComponentSerialization.CODEC.decode(lookup().createSerializationContext(JsonOps.INSTANCE), serialized).getOrThrow().getFirst()
98+
);
9599

96100
assertJsonTreesEqual(serializedNative, serialized);
97101
}

fabric/src/testmod/java/net/kyori/adventure/platform/test/fabric/AdventureFabricTester.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public void onInitialize() {
198198
}));
199199
return 1;
200200
}))))
201-
.then(literal("sound").then(argument(ARG_SOUND, key()).suggests(SuggestionProviders.AVAILABLE_SOUNDS).executes(ctx -> {
201+
.then(literal("sound").then(argument(ARG_SOUND, key()).suggests(SuggestionProviders.cast(SuggestionProviders.AVAILABLE_SOUNDS)).executes(ctx -> {
202202
final Audience viewer = this.adventure().audience(ctx.getSource());
203203
final Key sound = key(ctx, ARG_SOUND);
204204
viewer.sendMessage(text(b -> b.content("Playing sound ").append(represent(sound)).color(COLOR_RESPONSE)));

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=net.kyori
2-
version=6.4.1-SNAPSHOT
2+
version=6.5.0-SNAPSHOT
33
description=Integration between the adventure library and Minecraft: Java Edition, using the Fabric and NeoForge modding systems
44

55
javadocPublishRoot=https://jd.advntr.dev/platform/

gradle/libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
format = { version = "1.1" }
33

44
[versions]
5-
adventure = "4.21.0"
5+
adventure = "4.23.0"
66
adventurePlatform = "4.4.0"
77
ansi = "1.1.1"
88
autoService = "1.1.1"
99
checkstyle = "10.25.0"
1010
examination = "1.3.0"
11-
fabricApi = "0.121.0+1.21.5"
11+
fabricApi = "0.127.0+1.21.6"
1212
fabricLoader = "0.16.14"
1313
indra = "3.1.3"
1414
junit = "5.13.1"
15-
minecraft = "1.21.5"
16-
parchment = "1.21.5:2025.04.19"
15+
minecraft = "1.21.6"
16+
parchment = "1.21.5:2025.06.15"
1717
vineflower = "1.11.1"
1818
spotless = "7.0.4"
19-
neoforge = "21.5.63-beta"
20-
neoform = "1.21.5-20250325.162830"
19+
neoforge = "21.6.4-beta"
20+
neoform = "1.21.6-20250617.151856"
2121

2222
[libraries]
2323
adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }

mod-shared/src/client/java/net/kyori/adventure/platform/modcommon/impl/client/mixin/minecraft/player/LocalPlayerMixin.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2020-2024 KyoriPowered
4+
* Copyright (c) 2020-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -35,7 +35,6 @@
3535
import net.kyori.adventure.sound.Sound;
3636
import net.minecraft.client.Minecraft;
3737
import net.minecraft.client.player.LocalPlayer;
38-
import net.minecraft.core.BlockPos;
3938
import net.minecraft.world.entity.player.Player;
4039
import net.minecraft.world.level.Level;
4140
import org.jetbrains.annotations.NotNull;
@@ -53,8 +52,8 @@ public abstract class LocalPlayerMixin extends Player implements ForwardingAudie
5352

5453
private final Audience adventure$default = MinecraftClientAudiences.of().audience();
5554

56-
private LocalPlayerMixin(final Level level, final BlockPos blockPos, final float f, final GameProfile gameProfile) {
57-
super(level, blockPos, f, gameProfile);
55+
private LocalPlayerMixin(final Level p_250508_, final GameProfile p_252153_) {
56+
super(p_250508_, p_252153_);
5857
}
5958

6059
@Override

mod-shared/src/main/java/net/kyori/adventure/platform/modcommon/impl/AdventureCommon.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2024 KyoriPowered
4+
* Copyright (c) 2024-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -46,7 +46,6 @@
4646
import net.kyori.adventure.text.TranslationArgument;
4747
import net.kyori.adventure.text.flattener.ComponentFlattener;
4848
import net.kyori.adventure.translation.GlobalTranslator;
49-
import net.kyori.adventure.translation.TranslationRegistry;
5049
import net.kyori.adventure.translation.Translator;
5150
import net.kyori.adventure.util.Services;
5251
import net.minecraft.core.Holder;
@@ -107,7 +106,7 @@ private static ComponentFlattener createFlattener(final SidedProxy proxy) {
107106
flattenerBuilder.complexMapper(TranslatableComponent.class, (translatable, consumer) -> {
108107
final String key = translatable.key();
109108
for (final Translator registry : GlobalTranslator.translator().sources()) {
110-
if (registry instanceof TranslationRegistry tr && tr.contains(key)) {
109+
if (registry.canTranslate(key, Locale.getDefault())) {
111110
consumer.accept(GlobalTranslator.render(translatable, Locale.getDefault()));
112111
return;
113112
}

mod-shared/src/main/java/net/kyori/adventure/platform/modcommon/impl/NonWrappingComponentSerializer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of adventure-platform-mod, licensed under the MIT License.
33
*
4-
* Copyright (c) 2020-2024 KyoriPowered
4+
* Copyright (c) 2020-2025 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +24,7 @@
2424
package net.kyori.adventure.platform.modcommon.impl;
2525

2626
import com.google.common.base.Suppliers;
27+
import com.google.gson.JsonElement;
2728
import com.google.gson.JsonParseException;
2829
import com.mojang.serialization.JsonOps;
2930
import java.util.function.Supplier;
@@ -34,7 +35,6 @@
3435
import net.minecraft.core.RegistryAccess;
3536
import net.minecraft.core.registries.BuiltInRegistries;
3637
import net.minecraft.network.chat.ComponentSerialization;
37-
import net.minecraft.network.chat.MutableComponent;
3838
import org.jetbrains.annotations.NotNull;
3939

4040
public final class NonWrappingComponentSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> {
@@ -68,11 +68,15 @@ public Component deserialize(final net.minecraft.network.chat.Component input) {
6868
}
6969

7070
@Override
71-
public MutableComponent serialize(final Component component) {
71+
public net.minecraft.network.chat.Component serialize(final Component component) {
7272
BYPASS_IS_ALLOWED_FROM_SERVER.set(true);
73-
final MutableComponent mutableComponent;
73+
final net.minecraft.network.chat.Component mutableComponent;
7474
try {
75-
mutableComponent = net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serializeToTree(component), this.holderProvider.get());
75+
final JsonElement jsonElement = GsonComponentSerializer.gson().serializeToTree(component);
76+
mutableComponent = ComponentSerialization.CODEC
77+
.decode(this.holderProvider.get().createSerializationContext(JsonOps.INSTANCE), jsonElement)
78+
.getOrThrow(JsonParseException::new)
79+
.getFirst();
7680
} finally {
7781
BYPASS_IS_ALLOWED_FROM_SERVER.set(false);
7882
}

mod-shared/src/main/java/net/kyori/adventure/platform/modcommon/impl/service/GsonComponentSerializerProviderImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public final class GsonComponentSerializerProviderImpl implements GsonComponentS
5555
public @NotNull Consumer<GsonComponentSerializer.Builder> builder() {
5656
return builder -> builder
5757
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE)
58-
.options(JSONOptions.byDataVersion().at(SharedConstants.getCurrentVersion().getDataVersion().getVersion()));
58+
.options(JSONOptions.byDataVersion().at(SharedConstants.getCurrentVersion().dataVersion().version()));
5959
}
6060
}

0 commit comments

Comments
 (0)