1.4.113 on 23w31a, many regressions including modded networking, fake players, scoreboard api and more.
This commit is contained in:
1 parent
8416a2f28b
commit
55a88c6cdc
25 files changed
+356
-109
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
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(ClientCommonPacketListenerImpl.class)
|
||||
public class ClientCommonPacketListenerImpl_customPacketMixin
|
||||
{
|
||||
@Inject(method = "onDisconnect", at = @At("HEAD"))
|
||||
private void onCMDisconnected(Component reason, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.disconnect();
|
||||
}
|
||||
|
||||
@Inject(method = "handleCustomPayload(Lnet/minecraft/network/protocol/common/ClientboundCustomPayloadPacket;)V",
|
||||
at = @At("HEAD"))
|
||||
private void onOnCustomPayload(ClientboundCustomPayloadPacket packet, CallbackInfo ci)
|
||||
{
|
||||
//System.out.println("CustomPayload of : " + packet.payload());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,11 @@ package carpet.mixins;
|
||||
import carpet.CarpetServer;
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.multiplayer.CommonListenerCookie;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.Connection;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -13,9 +16,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public class ClientPacketListener_clientCommandMixin
|
||||
public abstract class ClientPacketListener_clientCommandMixin extends ClientCommonPacketListenerImpl
|
||||
{
|
||||
@Shadow @Final private Minecraft minecraft;
|
||||
|
||||
protected ClientPacketListener_clientCommandMixin(final Minecraft minecraft, final Connection connection, final CommonListenerCookie commonListenerCookie)
|
||||
{
|
||||
super(minecraft, connection, commonListenerCookie);
|
||||
}
|
||||
|
||||
@Inject(method = "sendCommand", at = @At("HEAD"))
|
||||
private void inspectMessage(String string, CallbackInfo ci)
|
||||
|
||||
@@ -3,41 +3,39 @@ package carpet.mixins;
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ClientNetworkHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.game.ClientboundCustomPayloadPacket;
|
||||
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
|
||||
public abstract class ClientPacketListener_customPacketsMixin extends ClientCommonPacketListenerImpl
|
||||
{
|
||||
@Final @Shadow private Minecraft minecraft;
|
||||
|
||||
@Inject(method = "handleCustomPayload", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundCustomPayloadPacket;getIdentifier()Lnet/minecraft/resources/ResourceLocation;"), cancellable = true)
|
||||
private void onOnCustomPayload(ClientboundCustomPayloadPacket packet, CallbackInfo ci)
|
||||
protected ClientPacketListener_customPacketsMixin(final Minecraft minecraft, final Connection connection, final CommonListenerCookie commonListenerCookie)
|
||||
{
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(packet.getIdentifier()))
|
||||
{
|
||||
ClientNetworkHandler.handleData(packet.getData(), minecraft.player);
|
||||
ci.cancel();
|
||||
}
|
||||
super(minecraft, connection, commonListenerCookie);
|
||||
}
|
||||
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
private void onGameJoined(ClientboundLoginPacket packet, CallbackInfo info)
|
||||
{
|
||||
CarpetClient.gameJoined(minecraft.player);
|
||||
CarpetClient.gameJoined( minecraft.player);
|
||||
}
|
||||
|
||||
@Inject(method = "onDisconnect", at = @At("HEAD"))
|
||||
private void onCMDisconnected(Component reason, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.disconnect();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package carpet.mixins;
|
||||
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ClientNetworkHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
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.resources.ResourceLocation;
|
||||
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.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(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())
|
||||
{
|
||||
ClientNetworkHandler.handleData(friendlyByteBuf, Minecraft.getInstance().player);
|
||||
cir.setReturnValue(new DiscardedPayload(resourceLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public abstract class Connection_packetCounterMixin implements ClientConnectionI
|
||||
|
||||
// Add to the packet counter whenever a packet is sent.
|
||||
@Inject(method = "sendPacket", at = @At("HEAD"))
|
||||
private void packetOutCount(Packet<?> packet, @Nullable PacketSendListener packetSendListener, CallbackInfo ci)
|
||||
private void packetOutCount(final Packet<?> packet, final PacketSendListener packetSendListener, final boolean bl, final CallbackInfo ci)
|
||||
{
|
||||
PacketCounter.totalOut++;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MinecraftMixin implements MinecraftInterface
|
||||
{
|
||||
@Shadow public ClientLevel level;
|
||||
|
||||
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
|
||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
|
||||
private void onCloseGame(Screen screen, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.disconnect();
|
||||
|
||||
@@ -16,7 +16,7 @@ public class PlayerList_coreMixin
|
||||
{
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("RETURN"))
|
||||
private void onPlayerConnected(Connection connection, ServerPlayer player, CallbackInfo ci)
|
||||
private void onPlayerConnected(Connection connection, ServerPlayer player, int i, CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onPlayerLoggedIn(player);
|
||||
}
|
||||
|
||||
@@ -34,21 +34,21 @@ public abstract class PlayerList_fakePlayersMixin
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "placeNewPlayer", at = @At(value = "NEW", target = "net/minecraft/server/network/ServerGamePacketListenerImpl"))
|
||||
private ServerGamePacketListenerImpl replaceNetworkHandler(MinecraftServer server, Connection clientConnection, ServerPlayer playerIn)
|
||||
@Redirect(method = "placeNewPlayer", at = @At(value = "NEW", target = "(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/network/Connection;Lnet/minecraft/server/level/ServerPlayer;I)Lnet/minecraft/server/network/ServerGamePacketListenerImpl;"))
|
||||
private ServerGamePacketListenerImpl replaceNetworkHandler( MinecraftServer server, Connection clientConnection, ServerPlayer playerIn, int i)
|
||||
{
|
||||
if (playerIn instanceof EntityPlayerMPFake fake)
|
||||
{
|
||||
return new NetHandlerPlayServerFake(this.server, clientConnection, fake);
|
||||
return new NetHandlerPlayServerFake(this.server, clientConnection, fake, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ServerGamePacketListenerImpl(this.server, clientConnection, playerIn);
|
||||
return new ServerGamePacketListenerImpl(this.server, clientConnection, playerIn, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "respawn", at = @At(value = "NEW", target = "net/minecraft/server/level/ServerPlayer"))
|
||||
public ServerPlayer makePlayerForRespawn(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, ServerPlayer serverPlayer, boolean bl)
|
||||
@Redirect(method = "respawn", at = @At(value = "NEW", target = "(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/server/level/ServerLevel;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/server/level/ServerPlayer;"))
|
||||
public ServerPlayer makePlayerForRespawn(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, ServerPlayer serverPlayer, boolean i)
|
||||
{
|
||||
if (serverPlayer instanceof EntityPlayerMPFake) {
|
||||
return EntityPlayerMPFake.respawnFake(minecraftServer, serverLevel, gameProfile);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.CarpetPacketPayload;
|
||||
import carpet.network.ServerNetworkHandler;
|
||||
import net.minecraft.network.protocol.PacketUtils;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ServerGamePacketListener;
|
||||
import net.minecraft.server.network.ServerCommonPacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
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(ServerCommonPacketListenerImpl.class)
|
||||
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) {
|
||||
// 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);
|
||||
ci.cancel();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package carpet.mixins;
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ServerNetworkHandler;
|
||||
import net.minecraft.network.protocol.PacketUtils;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ServerGamePacketListener;
|
||||
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
@@ -19,18 +19,5 @@ public class ServerGamePacketListenerImplMixin
|
||||
{
|
||||
@Shadow public ServerPlayer player;
|
||||
|
||||
@Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
private void onCustomCarpetPayload(ServerboundCustomPayloadPacket packet, CallbackInfo ci)
|
||||
{
|
||||
ResourceLocation channel = packet.getIdentifier();
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(channel))
|
||||
{
|
||||
// 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(packet, (ServerGamePacketListener) this, player.serverLevel());
|
||||
ServerNetworkHandler.handleData(packet.getData(), player);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
-2
@@ -1,7 +1,10 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerCommonPacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -11,13 +14,18 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
public abstract class ServerGamePacketListenerImpl_antiCheatDisabledMixin
|
||||
public abstract class ServerGamePacketListenerImpl_antiCheatDisabledMixin extends ServerCommonPacketListenerImpl
|
||||
{
|
||||
@Shadow private int aboveGroundTickCount;
|
||||
|
||||
@Shadow private int aboveGroundVehicleTickCount;
|
||||
|
||||
@Shadow protected abstract boolean isSingleplayerOwner();
|
||||
public ServerGamePacketListenerImpl_antiCheatDisabledMixin(final MinecraftServer minecraftServer, final Connection connection, final int i)
|
||||
{
|
||||
super(minecraftServer, connection, i);
|
||||
}
|
||||
|
||||
//@Shadow protected abstract boolean isSingleplayerOwner();
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void restrictFloatingBits(CallbackInfo ci)
|
||||
|
||||
@@ -4,7 +4,9 @@ import carpet.CarpetServer;
|
||||
import carpet.fakes.ServerGamePacketListenerImplInterface;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerCommonPacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -14,11 +16,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
public class ServerGamePacketListenerImpl_coreMixin implements ServerGamePacketListenerImplInterface {
|
||||
public abstract class ServerGamePacketListenerImpl_coreMixin extends ServerCommonPacketListenerImpl implements ServerGamePacketListenerImplInterface {
|
||||
@Shadow
|
||||
public ServerPlayer player;
|
||||
|
||||
@Shadow @Final private Connection connection;
|
||||
public ServerGamePacketListenerImpl_coreMixin(final MinecraftServer minecraftServer, final Connection connection, final int i)
|
||||
{
|
||||
super(minecraftServer, connection, i);
|
||||
}
|
||||
|
||||
@Inject(method = "onDisconnect", at = @At("HEAD"))
|
||||
private void onPlayerDisconnect(Component reason, CallbackInfo ci) {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
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)
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user