Readd BungeeCord support

This commit is contained in:
IzzelAliz 2022-10-06 15:17:59 +08:00
parent bf715d1d18
commit 2d042db449
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
3 changed files with 40 additions and 11 deletions

View File

@ -1,10 +0,0 @@
package io.izzel.arclight.common.mixin.core.commands.synchronization;
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ArgumentTypeInfos.class)
public abstract class ArgumentTypesMixin {
// TODO FIXME 1.19 command arguments
}

View File

@ -0,0 +1,39 @@
package io.izzel.arclight.common.mixin.core.network.protocol.game;
import com.mojang.brigadier.arguments.ArgumentType;
import io.netty.buffer.Unpooled;
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.registries.ForgeRegistries;
import org.spigotmc.SpigotConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "net.minecraft.network.protocol.game.ClientboundCommandsPacket$ArgumentNodeStub")
public class ClientboundCommandsPacket_ArgumentNodeStubMixin {
private static final int ARCLIGHT_WRAP_INDEX = -256;
@Inject(method = "serializeCap(Lnet/minecraft/network/FriendlyByteBuf;Lnet/minecraft/commands/synchronization/ArgumentTypeInfo;Lnet/minecraft/commands/synchronization/ArgumentTypeInfo$Template;)V",
cancellable = true, at = @At("HEAD"))
private static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>> void arclight$wrapArgument(FriendlyByteBuf buf, ArgumentTypeInfo<A, T> type, ArgumentTypeInfo.Template<A> node, CallbackInfo ci) {
if (!SpigotConfig.bungee) {
return;
}
var key = ForgeRegistries.COMMAND_ARGUMENT_TYPES.getKey(type);
if (key == null || key.getNamespace().equals("minecraft") || key.getNamespace().equals("brigadier")) {
return;
}
ci.cancel();
buf.writeVarInt(ARCLIGHT_WRAP_INDEX);
//noinspection deprecation
buf.writeVarInt(Registry.COMMAND_ARGUMENT_TYPE.getId(type));
var payload = new FriendlyByteBuf(Unpooled.buffer());
type.serializeToNetwork((T) node, payload);
buf.writeVarInt(payload.readableBytes());
buf.writeBytes(payload);
}
}

View File

@ -24,7 +24,6 @@
"commands.arguments.EntityArgumentMixin",
"commands.arguments.blocks.BlockStateParserMixin",
"commands.arguments.selector.EntitySelectorParserMixin",
"commands.synchronization.ArgumentTypesMixin",
"fluid.FlowingFluidMixin",
"fluid.LavaFluidMixin",
"nbt.CompoundTagMixin",
@ -39,6 +38,7 @@
"network.chat.TextColorMixin",
"network.protocol.PacketThreadUtilMixin",
"network.protocol.game.CCloseWindowPacketMixin",
"network.protocol.game.ClientboundCommandsPacket_ArgumentNodeStubMixin",
"network.protocol.game.ClientboundSectionBlocksUpdatePacketMixin",
"network.protocol.game.ClientboundSystemChatPacketMixin",
"network.protocol.game.CPlayerTryUseItemOnBlockPacketMixin",