From 59884f98340c54a178ea78a01530418e5557c423 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 27 Apr 2022 18:01:28 +0200 Subject: [PATCH] Fix Accidental Bug which causes Autoban --- ...etworkHandler.java => ClientWorldMixin.java} | 17 ++++++++++------- .../resources/SteamwarModSender.mixins.json | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) rename src/main/java/de/steamwar/modsender/mixin/{MixinClientPlayNetworkHandler.java => ClientWorldMixin.java} (69%) diff --git a/src/main/java/de/steamwar/modsender/mixin/MixinClientPlayNetworkHandler.java b/src/main/java/de/steamwar/modsender/mixin/ClientWorldMixin.java similarity index 69% rename from src/main/java/de/steamwar/modsender/mixin/MixinClientPlayNetworkHandler.java rename to src/main/java/de/steamwar/modsender/mixin/ClientWorldMixin.java index 8801fc5..8700524 100644 --- a/src/main/java/de/steamwar/modsender/mixin/MixinClientPlayNetworkHandler.java +++ b/src/main/java/de/steamwar/modsender/mixin/ClientWorldMixin.java @@ -16,19 +16,22 @@ package de.steamwar.modsender.mixin; import de.steamwar.modsender.ModSender; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.world.ClientWorld; 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(ClientPlayNetworkHandler.class) -public class MixinClientPlayNetworkHandler { +@Mixin(ClientWorld.class) +public class ClientWorldMixin { - @Inject(at = @At("TAIL"), method = "onGameJoin") - private void connect(GameJoinS2CPacket packet, CallbackInfo ci) { - ModSender.sendInformationPacket(); + @Inject(at = @At("HEAD"), method = "addPlayer") + private void onAddPlayer(int id, AbstractClientPlayerEntity player, CallbackInfo ci) { + if(player == MinecraftClient.getInstance().player) { + ModSender.sendInformationPacket(); + } } } diff --git a/src/main/resources/SteamwarModSender.mixins.json b/src/main/resources/SteamwarModSender.mixins.json index aa859f4..5b8fba9 100644 --- a/src/main/resources/SteamwarModSender.mixins.json +++ b/src/main/resources/SteamwarModSender.mixins.json @@ -6,7 +6,7 @@ "mixins": [ ], "client": [ - "MixinClientPlayNetworkHandler" + "ClientWorldMixin" ], "injectors": { "defaultRequire": 1