diff options
author | nea <romangraef@gmail.com> | 2022-09-28 12:45:56 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-09-28 12:45:56 +0200 |
commit | 4d73331a449f0b0647066f7dde0628730fe0e178 (patch) | |
tree | 047f463e13d14ea6cf9c8b37602a756f6880f9a0 /src/main/kotlin/moe/nea/notenoughupdates/mixins | |
parent | ec66c82198fe2d61d699d553c1254f08b43fcc65 (diff) | |
download | Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.tar.gz Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.tar.bz2 Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.zip |
Fairy souls
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/mixins')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt | 33 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt | 41 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt new file mode 100644 index 0000000..b6151b9 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt @@ -0,0 +1,33 @@ +package moe.nea.notenoughupdates.mixins + +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 +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 moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent + +@Mixin(MessageHandler::class) +class MixinMessageHandler { + @Inject(method = ["onChatMessage"], at = [At("HEAD")], cancellable = true) + fun onOnChatMessage(message: SignedMessage, params: MessageType.Parameters, ci: CallbackInfo) { + val decoratedText = params.applyChatDecoration(message.unsignedContent.orElse(message.content)) + val event = ServerChatLineReceivedEvent(decoratedText) + if (ServerChatLineReceivedEvent.publish(event).cancelled) { + ci.cancel() + } + } + + @Inject(method = ["onGameMessage"], at = [At("HEAD")], cancellable = true) + fun onOnGameMessage(message: Text, overlay: Boolean, ci: CallbackInfo) { + if (!overlay) { + val event = ServerChatLineReceivedEvent(message) + if (ServerChatLineReceivedEvent.publish(event).cancelled) { + ci.cancel() + } + } + } +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt new file mode 100644 index 0000000..ac9ea15 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt @@ -0,0 +1,41 @@ +package moe.nea.notenoughupdates.mixins + +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 +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 net.minecraft.util.math.Matrix4f +import moe.nea.notenoughupdates.events.WorldRenderLastEvent + +@Mixin(WorldRenderer::class) +class MixinWorldRenderer { + + @Inject( + method = ["render"], + at = [At("INVOKE", target = "renderChunkDebugInfo", shift = At.Shift.AFTER)], + ) + fun onWorldRenderLast( + matrices: MatrixStack, + tickDelta: Float, + arg2: Long, + renderBlockOutline: Boolean, + camera: Camera, + gameRenderer: GameRenderer, + lightmapTextureManager: LightmapTextureManager, + positionMatrix: Matrix4f, + ci: CallbackInfo + ) { + val event = WorldRenderLastEvent( + matrices, tickDelta, renderBlockOutline, + camera, gameRenderer, lightmapTextureManager, + positionMatrix + ) + WorldRenderLastEvent.publish(event) + } + +} |