aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-11-15 23:13:50 +0100
committerLinnea Gräf <nea@nea.moe>2025-11-15 23:13:50 +0100
commit4d8399ff4d769def62e6a8241327c4f2dac47e71 (patch)
tree703f8651cb680d2583d82c2b1b4aee0911ccb490 /src/main/kotlin/util
parent215178c650d38a4a77fdef6dc8815c07bef29c25 (diff)
downloadFirmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.gz
Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.bz2
Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.zip
snapshot: main source set compile
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/FragmentGuiScreen.kt31
-rw-r--r--src/main/kotlin/util/MC.kt1
-rw-r--r--src/main/kotlin/util/ScoreboardUtil.kt2
-rw-r--r--src/main/kotlin/util/SkyblockId.kt3
-rw-r--r--src/main/kotlin/util/customgui/CustomGui.kt15
-rw-r--r--src/main/kotlin/util/mc/CustomRenderPassHelper.kt3
-rw-r--r--src/main/kotlin/util/mc/NbtUtil.kt5
-rw-r--r--src/main/kotlin/util/mc/SkullItemData.kt4
8 files changed, 38 insertions, 26 deletions
diff --git a/src/main/kotlin/util/FragmentGuiScreen.kt b/src/main/kotlin/util/FragmentGuiScreen.kt
index de53ac0..74558a0 100644
--- a/src/main/kotlin/util/FragmentGuiScreen.kt
+++ b/src/main/kotlin/util/FragmentGuiScreen.kt
@@ -6,8 +6,11 @@ import io.github.notenoughupdates.moulconfig.gui.GuiContext
import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
+import net.minecraft.client.gui.Click
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.input.CharInput
+import net.minecraft.client.input.KeyInput
import net.minecraft.text.Text
abstract class FragmentGuiScreen(
@@ -29,15 +32,15 @@ abstract class FragmentGuiScreen(
return true
}
- override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ override fun keyPressed(input: KeyInput): Boolean {
return ifPopup {
- it.keyPressed(keyCode, scanCode, modifiers)
+ it.keyPressed(input)
}
}
- override fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ override fun keyReleased(input: KeyInput): Boolean {
return ifPopup {
- it.keyReleased(keyCode, scanCode, modifiers)
+ it.keyReleased(input)
}
}
@@ -45,35 +48,35 @@ abstract class FragmentGuiScreen(
ifPopup { it.mouseMoved(mouseX, mouseY) }
}
- override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ override fun mouseReleased(click: Click): Boolean {
return ifPopup {
- it.mouseReleased(mouseX, mouseY, button)
+ it.mouseReleased(click)
}
}
- override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
+ override fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
return ifPopup {
- it.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
+ it.mouseDragged(click, offsetX, offsetY)
}
}
- override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ override fun mouseClicked(click: Click, doubled: Boolean): Boolean {
return ifPopup {
if (!Rectangle(
it.position,
Dimension(it.guiContext.root.width, it.guiContext.root.height)
- ).contains(Point(mouseX, mouseY))
+ ).contains(Point(click.x, click.y))
&& dismissOnOutOfBounds
) {
popup = null
} else {
- it.mouseClicked(mouseX, mouseY, button)
+ it.mouseClicked(click, doubled)
}
- }|| super.mouseClicked(mouseX, mouseY, button)
+ }|| super.mouseClicked(click, doubled)
}
- override fun charTyped(chr: Char, modifiers: Int): Boolean {
- return ifPopup { it.charTyped(chr, modifiers) }
+ override fun charTyped(input: CharInput): Boolean {
+ return ifPopup { it.charTyped(input) }
}
override fun mouseScrolled(
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index d60e19c..9f3fe99 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -114,7 +114,6 @@ object MC {
inline val player: ClientPlayerEntity? get() = TestUtil.unlessTesting { instance.player }
inline val camera: Entity? get() = instance.cameraEntity
inline val stackInHand: ItemStack get() = player?.mainHandStack ?: ItemStack.EMPTY
- inline val guiAtlasManager get() = instance.guiAtlasManager
inline val world: ClientWorld? get() = TestUtil.unlessTesting { instance.world }
inline val playerName: String get() = player?.name?.unformattedString ?: MC.instance.session.username
inline var screen: Screen?
diff --git a/src/main/kotlin/util/ScoreboardUtil.kt b/src/main/kotlin/util/ScoreboardUtil.kt
index 0970892..f5f28b9 100644
--- a/src/main/kotlin/util/ScoreboardUtil.kt
+++ b/src/main/kotlin/util/ScoreboardUtil.kt
@@ -22,7 +22,7 @@ object ScoreboardUtil {
}
private fun getScoreboardLinesUncached(): List<Text> {
- val scoreboard = MC.player?.scoreboard ?: return listOf()
+ val scoreboard = MC.instance.world?.scoreboard ?: return listOf()
val activeObjective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR) ?: return listOf()
return scoreboard.getScoreboardEntries(activeObjective)
.filter { !it.hidden() }
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index 7e39a75..8fd32c7 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -36,6 +36,7 @@ import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.json.DashlessUUIDSerializer
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.mc.loreAccordingToNbt
+import moe.nea.firmament.util.mc.unsafeNbt
import moe.nea.firmament.util.skyblock.ScreenIdentification
import moe.nea.firmament.util.skyblock.ScreenType
@@ -137,7 +138,7 @@ var ItemStack.extraAttributes: NbtCompound
set(DataComponentTypes.CUSTOM_DATA, component)
component
}
- return customData.nbt
+ return customData.unsafeNbt
}
fun ItemStack.modifyExtraAttributes(block: (NbtCompound) -> Unit) {
diff --git a/src/main/kotlin/util/customgui/CustomGui.kt b/src/main/kotlin/util/customgui/CustomGui.kt
index 35c60ac..457632b 100644
--- a/src/main/kotlin/util/customgui/CustomGui.kt
+++ b/src/main/kotlin/util/customgui/CustomGui.kt
@@ -1,7 +1,10 @@
package moe.nea.firmament.util.customgui
import me.shedaniel.math.Rectangle
+import net.minecraft.client.gui.Click
import net.minecraft.client.gui.DrawContext
+import net.minecraft.client.input.CharInput
+import net.minecraft.client.input.KeyInput
import net.minecraft.screen.slot.Slot
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenPushREIEvent
@@ -30,7 +33,7 @@ abstract class CustomGui {
) {
}
- open fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ open fun mouseClick(click: Click, doubled: Boolean): Boolean {
return false
}
@@ -69,23 +72,23 @@ abstract class CustomGui {
return true
}
- open fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ open fun mouseReleased(click: Click): Boolean {
return false
}
- open fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
+ open fun mouseDragged(click: Click, offsetX: Double, offsetY: Double): Boolean {
return false
}
- open fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ open fun keyPressed(input: KeyInput): Boolean {
return false
}
- open fun charTyped(chr: Char, modifiers: Int): Boolean {
+ open fun charTyped(input: CharInput): Boolean {
return false
}
- open fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ open fun keyReleased(input: KeyInput): Boolean {
return false
}
}
diff --git a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
index 295f727..67fb2f8 100644
--- a/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
+++ b/src/main/kotlin/util/mc/CustomRenderPassHelper.kt
@@ -11,6 +11,7 @@ import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.util.OptionalDouble
import java.util.OptionalInt
+import org.joml.Vector3f
import org.joml.Vector4f
import net.minecraft.client.gl.Framebuffer
import net.minecraft.client.render.BufferBuilder
@@ -67,7 +68,7 @@ class CustomRenderPassHelper(
.write(
RenderSystem.getModelViewMatrix(),
Vector4f(1.0F, 1.0F, 1.0F, 1.0F),
- RenderSystem.getModelOffset(),
+ Vector3f(), // TODO: 1.21.10
RenderSystem.getTextureMatrix(),
RenderSystem.getShaderLineWidth()
)
diff --git a/src/main/kotlin/util/mc/NbtUtil.kt b/src/main/kotlin/util/mc/NbtUtil.kt
index 2cab1c7..5c47c28 100644
--- a/src/main/kotlin/util/mc/NbtUtil.kt
+++ b/src/main/kotlin/util/mc/NbtUtil.kt
@@ -1,10 +1,15 @@
package moe.nea.firmament.util.mc
+import net.minecraft.component.type.NbtComponent
import net.minecraft.nbt.NbtElement
import net.minecraft.nbt.NbtList
+import moe.nea.firmament.mixins.accessor.AccessorNbtComponent
fun Iterable<NbtElement>.toNbtList() = NbtList().also {
for (element in this) {
it.add(element)
}
}
+
+@Suppress("CAST_NEVER_SUCCEEDS")
+val NbtComponent.unsafeNbt get() = (this as AccessorNbtComponent).unsafeNbt_firmament
diff --git a/src/main/kotlin/util/mc/SkullItemData.kt b/src/main/kotlin/util/mc/SkullItemData.kt
index 3a4c508..6f8f24b 100644
--- a/src/main/kotlin/util/mc/SkullItemData.kt
+++ b/src/main/kotlin/util/mc/SkullItemData.kt
@@ -46,7 +46,7 @@ fun ItemStack.setEncodedSkullOwner(uuid: UUID, encodedData: String) {
assert(this.item == Items.PLAYER_HEAD)
val gameProfile = GameProfile(uuid, "LameGuy123")
gameProfile.properties.put(propertyTextures, Property(propertyTextures, encodedData.padToValidBase64()))
- this.set(DataComponentTypes.PROFILE, ProfileComponent(gameProfile))
+ this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
}
val arbitraryUUID = UUID.fromString("d3cb85e2-3075-48a1-b213-a9bfb62360c1")
@@ -63,7 +63,7 @@ fun ItemStack.setSkullOwner(uuid: UUID, url: String) {
profileName = "nea89",
)
)
- this.set(DataComponentTypes.PROFILE, ProfileComponent(gameProfile))
+ this.set(DataComponentTypes.PROFILE, ProfileComponent.ofStatic(gameProfile))
}