Wrap modded command arguments
This commit is contained in:
parent
10f6e37aa0
commit
d9463a511c
|
@ -0,0 +1,50 @@
|
|||
package io.izzel.arclight.common.mixin.core.command.arguments;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.command.arguments.ArgumentTypes;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mixin(ArgumentTypes.class)
|
||||
public abstract class ArgumentTypesMixin {
|
||||
|
||||
// @formatter:off
|
||||
@Shadow @Final private static Logger LOGGER;
|
||||
@Shadow @Nullable private static ArgumentTypes.Entry<?> get(ArgumentType<?> type) { return null; }
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* @author IzzelAliz
|
||||
* @reason
|
||||
*/
|
||||
@Overwrite
|
||||
public static <T extends ArgumentType<?>> void serialize(PacketBuffer buffer, T type) {
|
||||
ArgumentTypes.Entry<T> entry = (ArgumentTypes.Entry<T>) get(type);
|
||||
if (entry == null) {
|
||||
LOGGER.error("Could not serialize {} ({}) - will not be sent to client!", type, type.getClass());
|
||||
buffer.writeResourceLocation(new ResourceLocation(""));
|
||||
} else {
|
||||
String namespace = entry.id.getNamespace();
|
||||
boolean wrap = SpigotConfig.bungee && !(namespace.equals("minecraft") || namespace.equals("forge") || namespace.equals("brigadier"));
|
||||
if (wrap) {
|
||||
buffer.writeString("arclight:wrapped");
|
||||
}
|
||||
buffer.writeResourceLocation(entry.id);
|
||||
PacketBuffer buf = wrap ? new PacketBuffer(Unpooled.buffer()) : buffer;
|
||||
entry.serializer.write(type, buf);
|
||||
if (wrap) {
|
||||
buffer.writeVarInt(buf.writerIndex());
|
||||
buffer.writeBytes(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@ public net.minecraft.entity.player.SpawnLocationHelper func_241092_a_(Lnet/minec
|
|||
public net.minecraft.server.MinecraftServer field_240767_f_ #field_240767_f_
|
||||
public net.minecraftforge.registries.NamespacedWrapper
|
||||
public net.minecraftforge.registries.NamespacedDefaultedWrapper
|
||||
public net.minecraft.command.arguments.ArgumentTypes$Entry
|
||||
# Bukkit
|
||||
public net.minecraft.entity.player.PlayerEntity func_190531_bD()I
|
||||
public net.minecraft.entity.item.ItemFrameEntity func_174859_a(Lnet/minecraft/util/Direction;)V
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
"command.CommandsMixin",
|
||||
"command.CommandSourceMixin",
|
||||
"command.ICommandSourceMixin",
|
||||
"command.arguments.ArgumentTypesMixin",
|
||||
"command.arguments.BlockStateParserMixin",
|
||||
"command.arguments.EntityArgumentMixin",
|
||||
"command.arguments.EntitySelectorMixin",
|
||||
|
|
Loading…
Reference in New Issue
Block a user