Skip to content

Commit

Permalink
Readd BungeeCord support
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Oct 6, 2022
1 parent bf715d1 commit 2d042db
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"commands.arguments.EntityArgumentMixin",
"commands.arguments.blocks.BlockStateParserMixin",
"commands.arguments.selector.EntitySelectorParserMixin",
"commands.synchronization.ArgumentTypesMixin",
"fluid.FlowingFluidMixin",
"fluid.LavaFluidMixin",
"nbt.CompoundTagMixin",
Expand All @@ -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",
Expand Down

0 comments on commit 2d042db

Please sign in to comment.