move to play network hadnler so it doens't log in mc logs
this actually took ages beacuse i am dumb
This commit is contained in:
parent
2081ed9423
commit
a9972c323c
4 changed files with 41 additions and 49 deletions
|
@ -1,45 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
|
||||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
|
||||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
|
||||||
import land.chipmunk.chipmunkmod.modules.RainbowName;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
|
||||||
import net.minecraft.network.message.MessageSignatureData;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.text.TranslatableTextContent;
|
|
||||||
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(net.minecraft.client.gui.hud.ChatHud.class)
|
|
||||||
public class ChatHudMixin {
|
|
||||||
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true)
|
|
||||||
public void addMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
|
|
||||||
if (RainbowName.INSTANCE.enabled) {
|
|
||||||
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
|
|
||||||
ci.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (((TranslatableTextContent) message.getContent()).getKey().equals("advMode.setCommand.success")) {
|
|
||||||
ci.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (ClassCastException ignored) {}
|
|
||||||
|
|
||||||
for (Listener listener : ListenerManager.listeners) {
|
|
||||||
listener.chatMessageReceived(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (((TextComponent) message.asComponent().children().get(0)).content().equals(ChomeNSBotCommandSuggestions.ID)) {
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,10 @@ package land.chipmunk.chipmunkmod.mixin;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||||
|
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
|
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
import land.chipmunk.chipmunkmod.modules.*;
|
import land.chipmunk.chipmunkmod.modules.*;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.network.ClientDynamicRegistryType;
|
import net.minecraft.client.network.ClientDynamicRegistryType;
|
||||||
|
@ -12,9 +15,12 @@ import net.minecraft.client.util.telemetry.WorldSession;
|
||||||
import net.minecraft.command.CommandRegistryAccess;
|
import net.minecraft.command.CommandRegistryAccess;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||||
|
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
||||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableTextContent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -46,4 +52,38 @@ public class ClientPlayNetworkHandlerMixin {
|
||||||
|
|
||||||
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
||||||
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
|
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
|
||||||
|
|
||||||
|
|
||||||
|
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onGameMessage (GameMessageS2CPacket packet, CallbackInfo ci) {
|
||||||
|
final Text message = packet.content();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (RainbowName.INSTANCE.enabled) {
|
||||||
|
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
|
||||||
|
ci.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (((TranslatableTextContent) message.getContent()).getKey().equals("advMode.setCommand.success")) {
|
||||||
|
ci.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (ClassCastException ignored) {}
|
||||||
|
|
||||||
|
for (Listener listener : ListenerManager.listeners) {
|
||||||
|
listener.chatMessageReceived(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (((TextComponent) message.asComponent().children().get(0)).content().equals(ChomeNSBotCommandSuggestions.ID)) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,6 @@ public class ChomeNSBotCommandSuggestions extends Listener {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
ignored.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"package": "land.chipmunk.chipmunkmod.mixin",
|
"package": "land.chipmunk.chipmunkmod.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": [
|
"client": [
|
||||||
"ChatHudMixin",
|
|
||||||
"ChatInputSuggestorMixin",
|
"ChatInputSuggestorMixin",
|
||||||
"ChatScreenMixin",
|
"ChatScreenMixin",
|
||||||
"ClientConnectionMixin",
|
"ClientConnectionMixin",
|
||||||
|
|
Loading…
Reference in a new issue