aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/inventory/buttons/InventoryButtons.kt')
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index 47fdbe9..fa376bc 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -4,9 +4,9 @@ import me.shedaniel.math.Rectangle
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.text.Text
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -14,7 +14,7 @@ import moe.nea.firmament.events.HandledScreenPushREIEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.TimeMark
-import moe.nea.firmament.util.accessors.getRectangle
+import moe.nea.firmament.util.accessors.getProperRectangle
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.DataHolder
import moe.nea.firmament.util.data.ManagedConfig
@@ -39,7 +39,7 @@ object InventoryButtons {
var buttons: MutableList<InventoryButton> = mutableListOf()
)
- fun getValidButtons(screen: HandledScreen<*>): Sequence<InventoryButton> {
+ fun getValidButtons(screen: AbstractContainerScreen<*>): Sequence<InventoryButton> {
return DConfig.data.buttons.asSequence().filter { button ->
button.isValid() && (!TConfig.onlyInv || screen is InventoryScreen)
}
@@ -48,7 +48,7 @@ object InventoryButtons {
@Subscribe
fun onRectangles(it: HandledScreenPushREIEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
it.block(buttonBounds)
@@ -57,7 +57,7 @@ object InventoryButtons {
@Subscribe
fun onClickScreen(it: HandledScreenClickEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
if (buttonBounds.contains(it.mouseX, it.mouseY)) {
@@ -72,22 +72,22 @@ object InventoryButtons {
@Subscribe
fun onRenderForeground(it: HandledScreenForegroundEvent) {
- val bounds = it.screen.getRectangle()
+ val bounds = it.screen.getProperRectangle()
var hoveredComponent: InventoryButton? = null
for (button in getValidButtons(it.screen)) {
val buttonBounds = button.getBounds(bounds)
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(buttonBounds.minX.toFloat(), buttonBounds.minY.toFloat())
button.render(it.context)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
if (buttonBounds.contains(it.mouseX, it.mouseY) && TConfig.hoverText && hoveredComponent == null) {
hoveredComponent = button
if (lastMouseMove.passedTime() > 0.6.seconds && lastHoveredComponent === button) {
- it.context.drawTooltip(
+ it.context.setComponentTooltipForNextFrame(
MC.font,
- listOf(Text.literal(button.command).gold()),
+ listOf(Component.literal(button.command).gold()),
buttonBounds.minX - 15,
buttonBounds.maxY + 20,
)
@@ -105,8 +105,8 @@ object InventoryButtons {
ScreenUtil.setScreenLater(
InventoryButtonEditor(
lastRectangle ?: Rectangle(
- MC.window.scaledWidth / 2 - 88,
- MC.window.scaledHeight / 2 - 83,
+ MC.window.guiScaledWidth / 2 - 88,
+ MC.window.guiScaledHeight / 2 - 83,
176, 166,
)
)