fix client communication for carpet
This commit is contained in:
1 parent
08c5c3db31
commit
7a19bbe997
8 files changed
+70
-201
No files matched your search
@@ -1,11 +0,0 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface CarpetPacketPayload extends CustomPacketPayload
|
||||
{
|
||||
FriendlyByteBuf data();
|
||||
}
|
||||
@@ -7,21 +7,12 @@ import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.multiplayer.CommonListenerCookie;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.common.ClientCommonPacketListener;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public abstract class ClientPacketListener_customPacketsMixin extends ClientCommonPacketListenerImpl
|
||||
@@ -38,4 +29,16 @@ public abstract class ClientPacketListener_customPacketsMixin extends ClientComm
|
||||
CarpetClient.gameJoined( minecraft.player);
|
||||
}
|
||||
|
||||
@Inject(method = "handleUnknownCustomPayload", at = @At(
|
||||
value = "HEAD"
|
||||
), cancellable = true)
|
||||
private void onOnCustomPayload(CustomPacketPayload packet, CallbackInfo ci)
|
||||
{
|
||||
if (packet instanceof CarpetClient.CarpetPayload cpp)
|
||||
{
|
||||
ClientNetworkHandler.handleData(cpp, minecraft.player);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,19 +17,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(ClientboundCustomPayloadPacket.class)
|
||||
public class ClientboundCustomPayloadPacket_customPacketMixin
|
||||
{
|
||||
@Inject(method = "readPayload", at = @At("HEAD"))
|
||||
private static void onOnCustomPayloadR(final ResourceLocation resourceLocation, final FriendlyByteBuf friendlyByteBuf, final CallbackInfoReturnable<CustomPacketPayload> cir)
|
||||
@Inject(method = "readUnknownPayload", at = @At("HEAD"), cancellable = true)
|
||||
private static void onOnCustomPayloadR(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir)
|
||||
{
|
||||
}
|
||||
|
||||
@Inject(method = "readUnknownPayload", at = @At(value = "HEAD"), cancellable = true)
|
||||
private static void onOnCustomPayload(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<DiscardedPayload> cir)
|
||||
{
|
||||
if (true) return;
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(resourceLocation) && Minecraft.getInstance().isSameThread())
|
||||
if (resourceLocation.equals(CarpetClient.CARPET_CHANNEL))
|
||||
{
|
||||
ClientNetworkHandler.handleData(friendlyByteBuf, Minecraft.getInstance().player);
|
||||
cir.setReturnValue(new DiscardedPayload(resourceLocation));
|
||||
cir.setReturnValue(new CarpetClient.CarpetPayload(friendlyByteBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.CarpetPacketPayload;
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ServerNetworkHandler;
|
||||
import net.minecraft.network.protocol.PacketUtils;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
@@ -18,16 +18,14 @@ public class ServerCommonPacketListenerimpl_connectionMixin
|
||||
@Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
private void onCustomCarpetPayload(ServerboundCustomPayloadPacket serverboundCustomPayloadPacket, CallbackInfo ci)
|
||||
{
|
||||
if (true) return;
|
||||
Object thiss = this;
|
||||
if (thiss instanceof ServerGamePacketListenerImpl impl && serverboundCustomPayloadPacket.payload() instanceof CarpetPacketPayload cpp) {
|
||||
if (thiss instanceof ServerGamePacketListenerImpl impl && serverboundCustomPayloadPacket.payload() instanceof CarpetClient.CarpetPayload cpp) {
|
||||
// We should force onto the main thread here
|
||||
// ServerNetworkHandler.handleData can possibly mutate data that isn't
|
||||
// thread safe, and also allows for client commands to be executed
|
||||
PacketUtils.ensureRunningOnSameThread(serverboundCustomPayloadPacket, (ServerGamePacketListener) this, impl.player.serverLevel());
|
||||
ServerNetworkHandler.handleData(cpp.data(), impl.player);
|
||||
ServerNetworkHandler.handleData(cpp, impl.player);
|
||||
ci.cancel();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.CarpetPacketPayload;
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ClientNetworkHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -17,36 +13,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(ServerboundCustomPayloadPacket.class)
|
||||
public class ServerboundCustomPayloadPacket_mixin
|
||||
{
|
||||
@Inject(method = "readPayload", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/protocol/common/ServerboundCustomPayloadPacket;readUnknownPayload(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/network/protocol/common/custom/DiscardedPayload;"
|
||||
), cancellable = true)
|
||||
@Inject(method = "readUnknownPayload", at = @At(value = "HEAD"), cancellable = true)
|
||||
private static void onOnCustomPayload(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir)
|
||||
{
|
||||
if (true) return;
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(resourceLocation))
|
||||
{
|
||||
//ClientNetworkHandler.handleData(friendlyByteBuf, Minecraft.getInstance().player);
|
||||
cir.setReturnValue(new CarpetPacketPayload()
|
||||
{
|
||||
@Override
|
||||
public FriendlyByteBuf data()
|
||||
{
|
||||
return friendlyByteBuf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final FriendlyByteBuf friendlyByteBuf)
|
||||
{
|
||||
// noop - its a client side and we handle it server side only
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id()
|
||||
{
|
||||
return resourceLocation;
|
||||
}
|
||||
});
|
||||
cir.setReturnValue(new CarpetClient.CarpetPayload(friendlyByteBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,21 @@ import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class CarpetClient
|
||||
{
|
||||
public record CarpetPayload(CompoundTag data) implements CustomPacketPayload
|
||||
public record CarpetPayload(int command, CompoundTag data) implements CustomPacketPayload
|
||||
{
|
||||
public static final ResourceLocation ID = CARPET_CHANNEL;
|
||||
|
||||
public CarpetPayload(final FriendlyByteBuf input) {
|
||||
this(input.readNbt());
|
||||
public CarpetPayload(FriendlyByteBuf input) {
|
||||
this(input.readInt(), input.readNbt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final FriendlyByteBuf output) {
|
||||
public void write(FriendlyByteBuf output) {
|
||||
output.writeInt(command);
|
||||
output.writeNbt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return ID;
|
||||
return CARPET_CHANNEL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,22 +99,18 @@ public class ClientNetworkHandler
|
||||
};
|
||||
|
||||
// Ran on the Main Minecraft Thread
|
||||
public static void handleData(FriendlyByteBuf data, LocalPlayer player)
|
||||
public static void handleData(CarpetClient.CarpetPayload data, LocalPlayer player)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
int id = data.readVarInt();
|
||||
if (id == CarpetClient.HI)
|
||||
onHi(data);
|
||||
if (id == CarpetClient.DATA)
|
||||
onSyncData(data, player);
|
||||
}
|
||||
if (data.command() == CarpetClient.HI)
|
||||
onHi(data.data());
|
||||
if (data.command() == CarpetClient.DATA)
|
||||
onSyncData(data.data(), player);
|
||||
}
|
||||
|
||||
private static void onHi(FriendlyByteBuf data)
|
||||
private static void onHi(CompoundTag data)
|
||||
{
|
||||
CarpetClient.setCarpet();
|
||||
CarpetClient.serverCarpetVersion = data.readUtf(64);
|
||||
CarpetClient.serverCarpetVersion = data.getString("version");
|
||||
if (CarpetSettings.carpetVersion.equals(CarpetClient.serverCarpetVersion))
|
||||
{
|
||||
CarpetSettings.LOG.info("Joined carpet server with matching carpet version");
|
||||
@@ -130,28 +126,15 @@ public class ClientNetworkHandler
|
||||
|
||||
public static void respondHello()
|
||||
{
|
||||
CompoundTag data = new CompoundTag();
|
||||
data.putString("version", CarpetSettings.carpetVersion);
|
||||
CarpetClient.getPlayer().connection.send(new ServerboundCustomPayloadPacket(
|
||||
new CustomPacketPayload()
|
||||
{
|
||||
@Override
|
||||
public void write(final FriendlyByteBuf friendlyByteBuf)
|
||||
{
|
||||
friendlyByteBuf.writeVarInt(CarpetClient.HELLO).writeUtf(CarpetSettings.carpetVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id()
|
||||
{
|
||||
return CarpetClient.CARPET_CHANNEL;
|
||||
}
|
||||
}
|
||||
new CarpetClient.CarpetPayload(CarpetClient.HELLO, data)
|
||||
));
|
||||
}
|
||||
|
||||
private static void onSyncData(FriendlyByteBuf data, LocalPlayer player)
|
||||
private static void onSyncData(CompoundTag compound, LocalPlayer player)
|
||||
{
|
||||
CompoundTag compound = data.readNbt();
|
||||
if (compound == null) return;
|
||||
for (String key: compound.getAllKeys())
|
||||
{
|
||||
if (dataHandlers.containsKey(key)) {
|
||||
@@ -176,20 +159,7 @@ public class ClientNetworkHandler
|
||||
CompoundTag outer = new CompoundTag();
|
||||
outer.put("clientCommand", tag);
|
||||
CarpetClient.getPlayer().connection.send(new ServerboundCustomPayloadPacket(
|
||||
new CustomPacketPayload()
|
||||
{
|
||||
@Override
|
||||
public void write( FriendlyByteBuf friendlyByteBuf)
|
||||
{
|
||||
friendlyByteBuf.writeVarInt(CarpetClient.DATA).writeNbt(outer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id()
|
||||
{
|
||||
return CarpetClient.CARPET_CHANNEL;
|
||||
}
|
||||
}
|
||||
new CarpetClient.CarpetPayload(CarpetClient.DATA, outer)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,11 @@ import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.api.settings.CarpetRule;
|
||||
import carpet.api.settings.RuleHelper;
|
||||
import carpet.fakes.CarpetPacketPayload;
|
||||
import carpet.fakes.MinecraftServerInterface;
|
||||
import carpet.fakes.ServerGamePacketListenerImplInterface;
|
||||
import carpet.helpers.ServerTickRateManager;
|
||||
import carpet.script.utils.SnoopyCommandSource;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -17,7 +16,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -34,22 +32,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class ServerNetworkHandler
|
||||
{
|
||||
@FunctionalInterface
|
||||
public interface CarpetCustomPayload extends CustomPacketPayload
|
||||
{
|
||||
void writeData(FriendlyByteBuf output);
|
||||
|
||||
@Override
|
||||
default void write(FriendlyByteBuf output) {
|
||||
writeData(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
default ResourceLocation id()
|
||||
{
|
||||
return CarpetClient.CARPET_CHANNEL;
|
||||
}
|
||||
}
|
||||
private static final Map<ServerPlayer, String> remoteCarpetPlayers = new HashMap<>();
|
||||
private static final Set<ServerPlayer> validCarpetPlayers = new HashSet<>();
|
||||
|
||||
@@ -59,43 +41,31 @@ public class ServerNetworkHandler
|
||||
}
|
||||
);
|
||||
|
||||
public static void handleData(FriendlyByteBuf data, ServerPlayer player)
|
||||
public static void handleData(CarpetClient.CarpetPayload data, ServerPlayer player)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
int id = data.readVarInt();
|
||||
if (id == CarpetClient.HELLO)
|
||||
onHello(player, data);
|
||||
if (id == CarpetClient.DATA)
|
||||
onClientData(player, data);
|
||||
}
|
||||
int id = data.command();
|
||||
if (id == CarpetClient.HELLO)
|
||||
onHello(player, data.data());
|
||||
if (id == CarpetClient.DATA)
|
||||
onClientData(player, data.data());
|
||||
}
|
||||
|
||||
private static ClientboundCustomPayloadPacket make(DataBuilder builder) {
|
||||
CarpetClient.CarpetPayload carpetPayload = builder.build();
|
||||
return new ClientboundCustomPayloadPacket(carpetPayload);
|
||||
}
|
||||
|
||||
|
||||
private static ClientboundCustomPayloadPacket make(Consumer<FriendlyByteBuf> accepter) {
|
||||
return new ClientboundCustomPayloadPacket(
|
||||
new CarpetCustomPayload()
|
||||
{
|
||||
@Override
|
||||
public void writeData(final FriendlyByteBuf t)
|
||||
{
|
||||
accepter.accept(t);
|
||||
}
|
||||
}
|
||||
);
|
||||
private static ClientboundCustomPayloadPacket make(int command, CompoundTag data) {
|
||||
return new ClientboundCustomPayloadPacket(new CarpetClient.CarpetPayload(command, data));
|
||||
}
|
||||
|
||||
public static void onPlayerJoin(ServerPlayer playerEntity)
|
||||
{
|
||||
if (true) return;
|
||||
if (!((ServerGamePacketListenerImplInterface)playerEntity.connection).getConnection().isMemoryConnection())
|
||||
{
|
||||
playerEntity.connection.send( make( output -> {
|
||||
output.writeVarInt(CarpetClient.HI);
|
||||
output.writeUtf(CarpetSettings.carpetVersion);
|
||||
}
|
||||
));
|
||||
CompoundTag data = new CompoundTag();
|
||||
data.putString("version", CarpetSettings.carpetVersion);
|
||||
playerEntity.connection.send( make( CarpetClient.HI, data));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -103,11 +73,10 @@ public class ServerNetworkHandler
|
||||
}
|
||||
}
|
||||
|
||||
public static void onHello(ServerPlayer playerEntity, FriendlyByteBuf packetData)
|
||||
public static void onHello(ServerPlayer playerEntity, CompoundTag packetData)
|
||||
{
|
||||
if (true) return;
|
||||
validCarpetPlayers.add(playerEntity);
|
||||
String clientVersion = packetData.readUtf(64);
|
||||
String clientVersion = packetData.getString("version");
|
||||
remoteCarpetPlayers.put(playerEntity, clientVersion);
|
||||
if (clientVersion.equals(CarpetSettings.carpetVersion))
|
||||
CarpetSettings.LOG.info("Player "+playerEntity.getName().getString()+" joined with a matching carpet client");
|
||||
@@ -115,14 +84,13 @@ public class ServerNetworkHandler
|
||||
CarpetSettings.LOG.warn("Player "+playerEntity.getName().getString()+" joined with another carpet version: "+clientVersion);
|
||||
DataBuilder data = DataBuilder.create(playerEntity.server); // tickrate related settings are sent on world change
|
||||
CarpetServer.forEachManager(sm -> sm.getCarpetRules().forEach(data::withRule));
|
||||
playerEntity.connection.send(make(data::build));
|
||||
playerEntity.connection.send(make(data));
|
||||
}
|
||||
|
||||
public static void sendPlayerLevelData(ServerPlayer player, ServerLevel level) {
|
||||
if (CarpetSettings.superSecretSetting || !validCarpetPlayers.contains(player)) return;
|
||||
DataBuilder data = DataBuilder.create(player.server).withTickRate().withFrozenState().withTickPlayerActiveTimeout(); // .withSuperHotState()
|
||||
player.connection.send(make(data::build));
|
||||
|
||||
player.connection.send(make(data));
|
||||
}
|
||||
|
||||
private static void handleClientCommand(ServerPlayer player, CompoundTag commandData)
|
||||
@@ -149,17 +117,12 @@ public class ServerNetworkHandler
|
||||
ListTag outputResult = new ListTag();
|
||||
for (Component line: output) outputResult.add(StringTag.valueOf(Component.Serializer.toJson(line)));
|
||||
if (!output.isEmpty()) result.put("output", outputResult);
|
||||
player.connection.send(make( butebuf ->
|
||||
DataBuilder.create(player.server).withCustomNbt("clientCommand", result).build(butebuf)
|
||||
));
|
||||
player.connection.send(make( DataBuilder.create(player.server).withCustomNbt("clientCommand", result)));
|
||||
// run command plug to command output,
|
||||
}
|
||||
|
||||
|
||||
private static void onClientData(ServerPlayer player, FriendlyByteBuf data)
|
||||
private static void onClientData(ServerPlayer player, CompoundTag compound)
|
||||
{
|
||||
CompoundTag compound = data.readNbt();
|
||||
if (compound == null) return;
|
||||
for (String key: compound.getAllKeys())
|
||||
{
|
||||
if (dataHandlers.containsKey(key))
|
||||
@@ -174,9 +137,7 @@ public class ServerNetworkHandler
|
||||
if (CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : remoteCarpetPlayers.keySet())
|
||||
{
|
||||
player.connection.send(make( output ->
|
||||
DataBuilder.create(player.server).withRule(rule).build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withRule(rule)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +146,7 @@ public class ServerNetworkHandler
|
||||
if (CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : validCarpetPlayers)
|
||||
{
|
||||
player.connection.send(make( output ->
|
||||
DataBuilder.create(player.server).withTickRate().build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withTickRate()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,9 +155,7 @@ public class ServerNetworkHandler
|
||||
if (CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : validCarpetPlayers)
|
||||
{
|
||||
player.connection.send(make( output ->
|
||||
DataBuilder.create(player.server).withFrozenState().build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withFrozenState()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,9 +164,7 @@ public class ServerNetworkHandler
|
||||
if(CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : validCarpetPlayers)
|
||||
{
|
||||
player.connection.send(make(output ->
|
||||
DataBuilder.create(player.server).withSuperHotState().build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withSuperHotState()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,9 +173,7 @@ public class ServerNetworkHandler
|
||||
if (CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : validCarpetPlayers)
|
||||
{
|
||||
player.connection.send(make(output ->
|
||||
DataBuilder.create(player.server).withTickPlayerActiveTimeout().build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withTickPlayerActiveTimeout()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,9 +182,7 @@ public class ServerNetworkHandler
|
||||
if (CarpetSettings.superSecretSetting) return;
|
||||
for (ServerPlayer player : validCarpetPlayers)
|
||||
{
|
||||
player.connection.send(make(output ->
|
||||
DataBuilder.create(player.server).withCustomNbt(command, data).build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withCustomNbt(command, data)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,13 +190,10 @@ public class ServerNetworkHandler
|
||||
{
|
||||
if (isValidCarpetPlayer(player))
|
||||
{
|
||||
player.connection.send(make(output ->
|
||||
DataBuilder.create(player.server).withCustomNbt(command, data).build(output)
|
||||
));
|
||||
player.connection.send(make(DataBuilder.create(player.server).withCustomNbt(command, data)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void onPlayerLoggedOut(ServerPlayer player)
|
||||
{
|
||||
validCarpetPlayers.remove(player);
|
||||
@@ -338,12 +286,9 @@ public class ServerNetworkHandler
|
||||
return this;
|
||||
}
|
||||
|
||||
private void build(FriendlyByteBuf packetBuf)
|
||||
private CarpetClient.CarpetPayload build()
|
||||
{
|
||||
packetBuf.writeVarInt(CarpetClient.DATA);
|
||||
packetBuf.writeNbt(tag);
|
||||
return new CarpetClient.CarpetPayload(CarpetClient.DATA, tag);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user