Skip to content

Commit

Permalink
Fixes #481
Browse files Browse the repository at this point in the history
  • Loading branch information
pietro-lopes committed Sep 24, 2024
1 parent b255be3 commit f47c08b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 104 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"client": [
"client.MixinClientConnection",
"client.MixinClientHandshakePacketListenerImpl",
"client.MixinClientPacketListener",
"client.MixinServerStatusPinger$1"
"client.MixinClientPacketListener"
],
"server": [],
"injectors": {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"client": [
"client.MixinClientConnection",
"client.MixinClientHandshakePacketListenerImpl",
"client.MixinClientPacketListener",
"client.MixinServerStatusPinger$1"
"client.MixinClientPacketListener"
],
"server": [],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.aizistral.nochatreports.common.mixins.client;

import java.lang.reflect.Field;
import java.net.InetSocketAddress;

import net.minecraft.client.multiplayer.ServerStatusPinger;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -12,7 +16,6 @@
import com.aizistral.nochatreports.common.core.ServerDataExtension;
import com.aizistral.nochatreports.common.platform.extensions.ServerPingerExtension;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
import net.minecraft.network.protocol.status.ServerStatus;
Expand All @@ -27,13 +30,20 @@ public abstract class MixinServerStatusPinger$1 implements ServerPingerExtension
* @author Aizistral (current version)
*/

@Unique
private ServerDataExtension nochatreports$serverData;

@Inject(method = "<init>", at = @At("RETURN"))
private void captureServerData(ServerStatusPinger serverStatusPinger, Connection connection, ServerData serverData, Runnable runnable, Runnable runnable2, InetSocketAddress inetSocketAddress, ServerAddress serverAddress, CallbackInfo ci){
nochatreports$serverData = (ServerDataExtension) serverData;
}

@Inject(method = "handleStatusResponse(Lnet/minecraft/network/protocol/status/ClientboundStatusResponsePacket;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/status/ServerStatus;"
+ "description()Lnet/minecraft/network/chat/Component;",
ordinal = 0, shift = At.Shift.BEFORE))
+ "description()Lnet/minecraft/network/chat/Component;"))
private void getNoChatReports(ClientboundStatusResponsePacket packet, CallbackInfo info) {
boolean preventsReports = ((ServerDataExtension) (Object) packet.status()).preventsChatReports();
((ServerDataExtension) this.getServerData()).setPreventsChatReports(preventsReports);
nochatreports$serverData.setPreventsChatReports(preventsReports);

if (NCRConfig.getCommon().enableDebugLog()) {
NCRCore.LOGGER.info("Received status response packet from server, preventsChatReports: {}",
Expand Down

0 comments on commit f47c08b

Please sign in to comment.