aboutsummaryrefslogtreecommitdiff
path: root/src/main
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
parenta8ab8f3d6326211f6e07694c64ebd8b6ba195988 (diff)
downloadfirmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.gz
firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.bz2
firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.zip
Modernize and 1.19.4ify
Diffstat (limited to 'src/main')
-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
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt2
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientBrandRetriever.kt18
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.kt17
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt33
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMinecraft.kt20
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt41
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt4
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt15
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt4
-rw-r--r--src/main/resources/fabric.mod.json4
-rw-r--r--src/main/resources/notenoughupdates.mixins.json3
15 files changed, 111 insertions, 153 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);
+ }
+}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt
index c230c9c..60b7e06 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt
@@ -1,10 +1,10 @@
package moe.nea.notenoughupdates.events
+import org.joml.Matrix4f
import net.minecraft.client.render.Camera
import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.LightmapTextureManager
import net.minecraft.client.util.math.MatrixStack
-import net.minecraft.util.math.Matrix4f
/**
* This event is called after all world rendering is done, but before any GUI rendering (including hand) has been done.
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientBrandRetriever.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientBrandRetriever.kt
deleted file mode 100644
index f5ccf23..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientBrandRetriever.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package moe.nea.notenoughupdates.mixins
-
-import org.spongepowered.asm.mixin.Mixin
-import org.spongepowered.asm.mixin.Overwrite
-import net.minecraft.client.ClientBrandRetriever
-
-@Mixin(ClientBrandRetriever::class)
-class MixinClientBrandRetriever {
-
-private companion object {
- @JvmStatic
- @Overwrite
- fun getClientModName(): String {
- return "penis"
- }
- }
-
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.kt
deleted file mode 100644
index b94ff65..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinClientPlayNetworkHandler.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-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.ClientPlayNetworkHandler
-import net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket
-import moe.nea.notenoughupdates.events.WorldReadyEvent
-
-@Mixin(ClientPlayNetworkHandler::class)
-class MixinClientPlayNetworkHandler {
- @Inject(method = ["onPlayerSpawnPosition"], at = [At("RETURN")])
- fun onOnPlayerSpawnPosition(packet: PlayerSpawnPositionS2CPacket, ci: CallbackInfo) {
- WorldReadyEvent.publish(WorldReadyEvent())
- }
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt
deleted file mode 100644
index b6151b9..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-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/MixinMinecraft.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMinecraft.kt
deleted file mode 100644
index 3bc1a5f..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMinecraft.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-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.MinecraftClient
-import net.minecraft.client.gui.screen.Screen
-import moe.nea.notenoughupdates.events.ScreenOpenEvent
-
-@Suppress("CAST_NEVER_SUCCEEDS")
-@Mixin(MinecraftClient::class)
-class MixinMinecraft {
- @Inject(method = ["setScreen"], at = [At("HEAD")], cancellable = true)
- fun onScreenChange(screen: Screen?, ci: CallbackInfo) {
- val event = ScreenOpenEvent((this as MinecraftClient).currentScreen, screen)
- if (ScreenOpenEvent.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
deleted file mode 100644
index ac9ea15..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-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)
- }
-
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
index c851758..6e88b42 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
@@ -16,10 +16,10 @@ import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
import moe.nea.notenoughupdates.repo.ItemCache.getIdentifier
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.item.ItemStack
-import net.minecraft.tag.TagKey
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import java.util.stream.Stream
+import net.minecraft.registry.tag.TagKey
object SBItemEntryDefinition : EntryDefinition<NEUItem> {
override fun equals(o1: NEUItem?, o2: NEUItem?, context: ComparisonContext?): Boolean {
@@ -61,7 +61,7 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> {
return null
}
- override fun getTagsFor(entry: EntryStack<NEUItem>?, value: NEUItem?): Stream<out TagKey<*>> {
+ override fun getTagsFor(entry: EntryStack<NEUItem>?, value: NEUItem?): Stream<out TagKey<*>>? {
return Stream.empty()
}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
index 5aad7fc..6d4af7e 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/SBData.kt
@@ -1,14 +1,11 @@
package moe.nea.notenoughupdates.util
-import java.time.Instant
import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
-import net.minecraft.network.message.ArgumentSignatureDataMap
-import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
import moe.nea.notenoughupdates.NotEnoughUpdates
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent
import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent
@@ -62,17 +59,7 @@ object SBData {
fun sendLocraw() {
lastLocrawSent = TimeSource.Monotonic.markNow()
val nh = MC.player?.networkHandler ?: return
- val ack = nh.consumeAcknowledgment()
- nh.sendPacket(
- CommandExecutionC2SPacket(
- "locraw",
- Instant.now(),
- 0L,
- ArgumentSignatureDataMap.EMPTY,
- false,
- ack
- )
- )
+nh.sendChatCommand("locraw")
}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
index 9b5432a..9a02996 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
@@ -22,7 +22,7 @@ class RenderBlockContext(val tesselator: Tessellator, val camPos: Vec3d) {
matrixStack.push()
matrixStack.translate(blockPos.x - camPos.x, blockPos.y - camPos.y, blockPos.z - camPos.z)
RenderSystem.applyModelViewMatrix()
- RenderSystem.setShader(GameRenderer::getPositionColorShader)
+ RenderSystem.setShader(GameRenderer::getPositionColorProgram)
buildCube(buffer)
tesselator.draw()
matrixStack.pop()
@@ -73,7 +73,6 @@ class RenderBlockContext(val tesselator: Tessellator, val camPos: Vec3d) {
fun renderBlocks(camera: Camera, block: RenderBlockContext. () -> Unit) {
RenderSystem.disableDepthTest()
- RenderSystem.disableTexture()
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
@@ -82,7 +81,6 @@ class RenderBlockContext(val tesselator: Tessellator, val camPos: Vec3d) {
VertexBuffer.unbind()
RenderSystem.enableDepthTest()
- RenderSystem.enableTexture()
RenderSystem.disableBlend()
}
}
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 66c18a3..64d7bb2 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -41,7 +41,7 @@
],
"depends": {
"fabric": "*",
- "fabric-language-kotlin": ">=1.8.2+kotlin.1.7.10",
- "minecraft": ">=1.18.2"
+ "fabric-language-kotlin": ">=${fabric_kotlin_version}",
+ "minecraft": ">=${minecraft_version}"
}
}
diff --git a/src/main/resources/notenoughupdates.mixins.json b/src/main/resources/notenoughupdates.mixins.json
index 7c1ec6b..52d30a7 100644
--- a/src/main/resources/notenoughupdates.mixins.json
+++ b/src/main/resources/notenoughupdates.mixins.json
@@ -6,8 +6,7 @@
"MixinClientPlayNetworkHandler",
"MixinMessageHandler",
"MixinMinecraft",
- "MixinWorldRenderer",
- "MixinClientBrandRetriever"
+ "MixinWorldRenderer"
],
"mixins": [
],