aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-03 00:52:37 +0200
committernea <nea@nea.moe>2023-05-03 00:52:49 +0200
commit3be33bb522f468b812bb59b7f2edc8d1ca352661 (patch)
tree1292a52cb661ab71584b1ae248204e18b869afe1 /src/main/java/moe
parenta8ab8f3d6326211f6e07694c64ebd8b6ba195988 (diff)
downloadfirmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.gz
firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.bz2
firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.zip
Modernize and 1.19.4ify
Diffstat (limited to 'src/main/java/moe')
-rw-r--r--src/main/java/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.java17
-rw-r--r--src/main/java/moe/nea/notenoughupdates/mixins/MixinMessageHandler.java34
-rw-r--r--src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java26
-rw-r--r--src/main/java/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.java26
4 files changed, 103 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.java b/src/main/java/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.java
new file mode 100644
index 0000000..34334b6
--- /dev/null
+++ b/src/main/java/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.java
@@ -0,0 +1,17 @@
+package moe.nea.notenoughupdates.mixins;
+
+import moe.nea.notenoughupdates.events.WorldReadyEvent;
+import net.minecraft.client.network.ClientPlayNetworkHandler;
+import net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket;
+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 {
+ @Inject(method = "onPlayerSpawnPosition", at = @At("RETURN"))
+ public void onOnPlayerSpawnPosition(PlayerSpawnPositionS2CPacket packet, CallbackInfo ci) {
+ WorldReadyEvent.Companion.publish(new WorldReadyEvent());
+ }
+}
diff --git a/src/main/java/moe/nea/notenoughupdates/mixins/MixinMessageHandler.java b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMessageHandler.java
new file mode 100644
index 0000000..5d3e70f
--- /dev/null
+++ b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMessageHandler.java
@@ -0,0 +1,34 @@
+package moe.nea.notenoughupdates.mixins;
+
+import com.mojang.authlib.GameProfile;
+import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent;
+import net.minecraft.client.network.message.MessageHandler;
+import net.minecraft.network.message.MessageType;
+import net.minecraft.network.message.SignedMessage;
+import net.minecraft.text.Text;
+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(MessageHandler.class)
+public class MixinMessageHandler {
+ @Inject(method = "onChatMessage", cancellable = true, at = @At("HEAD"))
+ public void onOnChatMessage(SignedMessage message, GameProfile sender, MessageType.Parameters params, CallbackInfo ci) {
+ var decoratedText = params.applyChatDecoration(message.unsignedContent() != null ? message.unsignedContent() : message.getContent());
+ var event = new ServerChatLineReceivedEvent(decoratedText);
+ if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
+ ci.cancel();
+ }
+ }
+
+ @Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
+ public void onOnGameMessage(Text message, boolean overlay, CallbackInfo ci) {
+ if (!overlay) {
+ var event = new ServerChatLineReceivedEvent(message);
+ if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
+ ci.cancel();
+ }
+ }
+ }
+}
diff --git a/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java
new file mode 100644
index 0000000..17f49e1
--- /dev/null
+++ b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java
@@ -0,0 +1,26 @@
+package moe.nea.notenoughupdates.mixins;
+
+import moe.nea.notenoughupdates.events.ScreenOpenEvent;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Screen;
+import org.jetbrains.annotations.Nullable;
+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;
+
+@Mixin(MinecraftClient.class)
+public abstract class MixinMinecraft {
+ @Shadow
+ @Nullable
+ public Screen currentScreen;
+
+ @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
+ public void onScreenChange(Screen screen, CallbackInfo ci) {
+ var event = new ScreenOpenEvent(currentScreen, screen);
+ if (ScreenOpenEvent.Companion.publish(event).getCancelled()) {
+ ci.cancel();
+ }
+ }
+}
diff --git a/src/main/java/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.java b/src/main/java/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.java
new file mode 100644
index 0000000..c3d70fe
--- /dev/null
+++ b/src/main/java/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.java
@@ -0,0 +1,26 @@
+package moe.nea.notenoughupdates.mixins;
+
+import moe.nea.notenoughupdates.events.WorldRenderLastEvent;
+import net.minecraft.client.render.Camera;
+import net.minecraft.client.render.GameRenderer;
+import net.minecraft.client.render.LightmapTextureManager;
+import net.minecraft.client.render.WorldRenderer;
+import net.minecraft.client.util.math.MatrixStack;
+import org.joml.Matrix4f;
+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(WorldRenderer.class)
+public class MixinWorldRenderer {
+ @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER))
+ public void onWorldRenderLast(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
+ var event = new WorldRenderLastEvent(
+ matrices, tickDelta, renderBlockOutline,
+ camera, gameRenderer, lightmapTextureManager,
+ positionMatrix
+ );
+ WorldRenderLastEvent.Companion.publish(event);
+ }
+}