aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/inventory
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-11-17 19:55:02 +0100
committerLinnea Gräf <nea@nea.moe>2025-11-17 19:55:02 +0100
commitc93a04a001b0f66b2724d46b04b6d1ed49a08d07 (patch)
tree5869ca70acc482ef0362f27785c3d3f1cbb9ffae /src/main/kotlin/features/inventory
parentaf9893b59407c69d31ebd2ed513f0396ab4d2dc9 (diff)
downloadFirmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.gz
Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.bz2
Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.zip
refactor: port to mojmaps
Diffstat (limited to 'src/main/kotlin/features/inventory')
-rw-r--r--src/main/kotlin/features/inventory/CraftingOverlay.kt26
-rw-r--r--src/main/kotlin/features/inventory/ItemRarityCosmetics.kt18
-rw-r--r--src/main/kotlin/features/inventory/JunkHighlighter.kt2
-rw-r--r--src/main/kotlin/features/inventory/PetFeatures.kt134
-rw-r--r--src/main/kotlin/features/inventory/PriceData.kt18
-rw-r--r--src/main/kotlin/features/inventory/REIDependencyWarner.kt26
-rw-r--r--src/main/kotlin/features/inventory/SaveCursorPosition.kt6
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt128
-rw-r--r--src/main/kotlin/features/inventory/TimerInLore.kt12
-rw-r--r--src/main/kotlin/features/inventory/WardrobeKeybinds.kt12
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButton.kt42
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt116
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonTemplates.kt4
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageBackingHandle.kt20
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt30
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt52
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt142
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt54
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/VirtualInventory.kt22
20 files changed, 447 insertions, 447 deletions
diff --git a/src/main/kotlin/features/inventory/CraftingOverlay.kt b/src/main/kotlin/features/inventory/CraftingOverlay.kt
index 30d2c6b..5241f54 100644
--- a/src/main/kotlin/features/inventory/CraftingOverlay.kt
+++ b/src/main/kotlin/features/inventory/CraftingOverlay.kt
@@ -1,9 +1,9 @@
package moe.nea.firmament.features.inventory
import io.github.moulberry.repo.data.NEUCraftingRecipe
-import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Formatting
+import net.minecraft.client.gui.screens.inventory.ContainerScreen
+import net.minecraft.world.item.ItemStack
+import net.minecraft.ChatFormatting
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -14,7 +14,7 @@ import moe.nea.firmament.util.skyblockId
object CraftingOverlay {
- private var screen: GenericContainerScreen? = null
+ private var screen: ContainerScreen? = null
private var recipe: NEUCraftingRecipe? = null
private var useNextScreen = false
private val craftingOverlayIndices = listOf(
@@ -24,7 +24,7 @@ object CraftingOverlay {
)
val CRAFTING_SCREEN_NAME = "Craft Item"
- fun setOverlay(screen: GenericContainerScreen?, recipe: NEUCraftingRecipe) {
+ fun setOverlay(screen: ContainerScreen?, recipe: NEUCraftingRecipe) {
this.screen = screen
if (screen == null) {
useNextScreen = true
@@ -34,7 +34,7 @@ object CraftingOverlay {
@Subscribe
fun onScreenChange(event: ScreenChangeEvent) {
- if (useNextScreen && event.new is GenericContainerScreen
+ if (useNextScreen && event.new is ContainerScreen
&& event.new.title?.string == "Craft Item"
) {
useNextScreen = false
@@ -50,11 +50,11 @@ object CraftingOverlay {
fun onSlotRender(event: SlotRenderEvents.After) {
val slot = event.slot
val recipe = this.recipe ?: return
- if (slot.inventory != screen?.screenHandler?.inventory) return
- val recipeIndex = craftingOverlayIndices.indexOf(slot.index)
+ if (slot.container != screen?.menu?.container) return
+ val recipeIndex = craftingOverlayIndices.indexOf(slot.containerSlot)
if (recipeIndex < 0) return
val expectedItem = recipe.inputs[recipeIndex]
- val actualStack = slot.stack ?: ItemStack.EMPTY!!
+ val actualStack = slot.item ?: ItemStack.EMPTY!!
val actualEntry = SBItemStack(actualStack)
if ((actualEntry.skyblockId != expectedItem.skyblockId || actualEntry.getStackSize() < expectedItem.amount)
&& expectedItem.amount.toInt() != 0
@@ -67,15 +67,15 @@ object CraftingOverlay {
0x80FF0000.toInt()
)
}
- if (!slot.hasStack()) {
+ if (!slot.hasItem()) {
val itemStack = SBItemStack(expectedItem)?.asImmutableItemStack() ?: return
- event.context.drawItem(itemStack, event.slot.x, event.slot.y)
- event.context.drawStackOverlay(
+ event.context.renderItem(itemStack, event.slot.x, event.slot.y)
+ event.context.renderItemDecorations(
MC.font,
itemStack,
event.slot.x,
event.slot.y,
- "${Formatting.RED}${expectedItem.amount.toInt()}"
+ "${ChatFormatting.RED}${expectedItem.amount.toInt()}"
)
}
}
diff --git a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
index 7a474f9..9712067 100644
--- a/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
+++ b/src/main/kotlin/features/inventory/ItemRarityCosmetics.kt
@@ -1,10 +1,10 @@
package moe.nea.firmament.features.inventory
import java.awt.Color
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.DrawContext
-import net.minecraft.item.ItemStack
-import net.minecraft.util.Identifier
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.GuiGraphics
+import net.minecraft.world.item.ItemStack
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HotbarItemRenderEvent
import moe.nea.firmament.events.SlotRenderEvents
@@ -23,16 +23,16 @@ object ItemRarityCosmetics {
}
private val rarityToColor = Rarity.colourMap.mapValues {
- val c = Color(it.value.colorValue!!)
+ val c = Color(it.value.color!!)
c.rgb
}
- fun drawItemStackRarity(drawContext: DrawContext, x: Int, y: Int, item: ItemStack) {
+ fun drawItemStackRarity(drawContext: GuiGraphics, x: Int, y: Int, item: ItemStack) {
val rarity = Rarity.fromItem(item) ?: return
val rgb = rarityToColor[rarity] ?: 0xFF00FF80.toInt()
- drawContext.drawGuiTexture(
+ drawContext.blitSprite(
RenderPipelines.GUI_TEXTURED,
- Identifier.of("firmament:item_rarity_background"),
+ ResourceLocation.parse("firmament:item_rarity_background"),
x, y,
16, 16,
rgb
@@ -43,7 +43,7 @@ object ItemRarityCosmetics {
@Subscribe
fun onRenderSlot(it: SlotRenderEvents.Before) {
if (!TConfig.showItemRarityBackground) return
- val stack = it.slot.stack ?: return
+ val stack = it.slot.item ?: return
drawItemStackRarity(it.context, it.slot.x, it.slot.y, stack)
}
diff --git a/src/main/kotlin/features/inventory/JunkHighlighter.kt b/src/main/kotlin/features/inventory/JunkHighlighter.kt
index 45d265e..15bdcfa 100644
--- a/src/main/kotlin/features/inventory/JunkHighlighter.kt
+++ b/src/main/kotlin/features/inventory/JunkHighlighter.kt
@@ -23,7 +23,7 @@ object JunkHighlighter {
if (!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
val junkRegex = TConfig.junkRegex.toPattern()
val slot = event.slot
- junkRegex.useMatch(slot.stack.getSearchName()) {
+ junkRegex.useMatch(slot.item.getSearchName()) {
event.context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, 0xffff0000.toInt())
}
}
diff --git a/src/main/kotlin/features/inventory/PetFeatures.kt b/src/main/kotlin/features/inventory/PetFeatures.kt
index 646989c..e0bb4b1 100644
--- a/src/main/kotlin/features/inventory/PetFeatures.kt
+++ b/src/main/kotlin/features/inventory/PetFeatures.kt
@@ -2,11 +2,11 @@ package moe.nea.firmament.features.inventory
import java.util.regex.Matcher
import org.joml.Vector2i
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HudRenderEvent
@@ -52,14 +52,14 @@ object PetFeatures {
val petOverlayHudStyle by choice("pet-overlay-hud-style") { PetOverlayHudStyles.PLAIN_NO_BACKGROUND }
}
- enum class PetOverlayHudStyles : StringIdentifiable {
+ enum class PetOverlayHudStyles : StringRepresentable {
PLAIN_NO_BACKGROUND,
COLOUR_NO_BACKGROUND,
PLAIN_BACKGROUND,
COLOUR_BACKGROUND,
ICON_ONLY;
- override fun asString() : String {
+ override fun getSerializedName() : String {
return name
}
}
@@ -86,7 +86,7 @@ object PetFeatures {
fun onSlotRender(event: SlotRenderEvents.Before) {
// Cache pets
petMenuTitle.useMatch(MC.screenName ?: return) {
- val stack = event.slot.stack
+ val stack = event.slot.item
if (!stack.isEmpty) cachePet(stack)
if (stack.petData?.active == true) {
if (currentPetUUID == "") currentPetUUID = stack.skyblockUUID.toString()
@@ -114,7 +114,7 @@ object PetFeatures {
fun onSlotClick(event: SlotClickEvent) {
// Check for switching/removing pet manually
petMenuTitle.useMatch(MC.screenName ?: return) {
- if (event.slot.inventory is PlayerInventory) return
+ if (event.slot.container is Inventory) return
if (event.button != 0 && event.button != 1) return
val petData = event.stack.petData ?: return
if (petData.active == true) {
@@ -175,23 +175,23 @@ object PetFeatures {
}
}
- private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Text>) {
+ private fun renderLinesAndBackground(it: HudRenderEvent, lines: List<Component>) {
// Render background for the hud
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
var maxWidth = 0
- lines.forEach { if (MC.font.getWidth(it) > maxWidth) maxWidth = MC.font.getWidth(it.unformattedString) }
- val height = if (MC.font.fontHeight * lines.size > 32) MC.font.fontHeight * lines.size else 32
+ lines.forEach { if (MC.font.width(it) > maxWidth) maxWidth = MC.font.width(it.unformattedString) }
+ val height = if (MC.font.lineHeight * lines.size > 32) MC.font.lineHeight * lines.size else 32
it.context.fill(0, -3, 40 + maxWidth, height + 2, 0x80000000.toInt())
}
// Render text for the hud
lines.forEachIndexed { index, line ->
- it.context.drawText(
+ it.context.drawString(
MC.font,
- line.copy().withColor(Formatting.GRAY),
+ line.copy().withColor(ChatFormatting.GRAY),
36,
- MC.font.fontHeight * index,
+ MC.font.lineHeight * index,
-1,
true
)
@@ -217,13 +217,13 @@ object PetFeatures {
val tabPet = PetParser.parseTabWidget(TabListAPI.getWidgetLines(TabListAPI.WidgetName.PET))
if (pet == null && tabPet == null && tempTabPet == null && tempChatPet == null) {
// No data on current pet
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
- val lines = mutableListOf<Text>()
- lines.add(Text.literal("" + Formatting.WHITE + "Unknown Pet"))
- lines.add(Text.literal("Open Pets Menu To Fix"))
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
+ val lines = mutableListOf<Component>()
+ lines.add(Component.literal("" + ChatFormatting.WHITE + "Unknown Pet"))
+ lines.add(Component.literal("Open Pets Menu To Fix"))
renderLinesAndBackground(it, lines)
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
return
}
if (pet == null) {
@@ -255,71 +255,71 @@ object PetFeatures {
// Set the text for the HUD
- val lines = mutableListOf<Text>()
+ val lines = mutableListOf<Component>()
if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.COLOUR_BACKGROUND) {
// Colour Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(pet.petItem))
+ lines.add(Component.literal(pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForNextLevel)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForNextLevel)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
- "" + Formatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
- Formatting.GOLD + "/" + Formatting.YELLOW +
- "${shortFormat(pet.expForMax)} " + Formatting.GOLD +
+ Component.literal(
+ "" + ChatFormatting.YELLOW + "Required L100: ${shortFormat(pet.totalExp)}" +
+ ChatFormatting.GOLD + "/" + ChatFormatting.YELLOW +
+ "${shortFormat(pet.expForMax)} " + ChatFormatting.GOLD +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
- "" + Formatting.AQUA + Formatting.BOLD + "MAX LEVEL"
+ lines.add(Component.literal(
+ "" + ChatFormatting.AQUA + ChatFormatting.BOLD + "MAX LEVEL"
))
- lines.add(Text.literal(
- "" + Formatting.GOLD + "+" + Formatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
+ lines.add(Component.literal(
+ "" + ChatFormatting.GOLD + "+" + ChatFormatting.YELLOW + "${shortFormat(pet.overflowExp)} XP"
))
}
} else if (TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_NO_BACKGROUND ||
TConfig.petOverlayHudStyle == PetOverlayHudStyles.PLAIN_BACKGROUND) {
// Plain Style
- lines.add(Text.literal("[Lvl ${pet.level}] ").append(Text.literal(pet.name)
- .withColor((Rarity.colourMap[pet.rarity]) ?: Formatting.WHITE)))
+ lines.add(Component.literal("[Lvl ${pet.level}] ").append(Component.literal(pet.name)
+ .withColor((Rarity.colourMap[pet.rarity]) ?: ChatFormatting.WHITE)))
- lines.add(Text.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
+ lines.add(Component.literal(if (pet.petItem != "None" && pet.petItem != "Unknown")
pet.petItem.substring(2) else pet.petItem))
if (pet.level != pet.maxLevel) {
// Exp data
lines.add(
- Text.literal(
+ Component.literal(
"Required L${pet.level + 1}: ${shortFormat(pet.currentExp)}/" +
"${shortFormat(pet.expForNextLevel)} " +
"(${formatPercent(pet.currentExp / pet.expForNextLevel)})"
)
)
lines.add(
- Text.literal(
+ Component.literal(
"Required L100: ${shortFormat(pet.totalExp)}/${shortFormat(pet.expForMax)} " +
"(${formatPercent(pet.totalExp / pet.expForMax)})"
)
)
} else {
// Overflow Exp data
- lines.add(Text.literal(
+ lines.add(Component.literal(
"MAX LEVEL"
))
- lines.add(Text.literal(
+ lines.add(Component.literal(
"+${shortFormat(pet.overflowExp)} XP"
))
}
@@ -327,19 +327,19 @@ object PetFeatures {
// Render HUD
- it.context.matrices.pushMatrix()
- TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.matrices)
+ it.context.pose().pushMatrix()
+ TConfig.petOverlayHud.applyTransformations(JarvisIntegration.jarvis, it.context.pose())
renderLinesAndBackground(it, lines)
// Draw the ItemStack
- it.context.matrices.pushMatrix()
- it.context.matrices.translate(-0.5F, -0.5F)
- it.context.matrices.scale(2f, 2f)
- it.context.drawItem(pet.petItemStack.value, 0, 0)
- it.context.matrices.popMatrix()
+ it.context.pose().pushMatrix()
+ it.context.pose().translate(-0.5F, -0.5F)
+ it.context.pose().scale(2f, 2f)
+ it.context.renderItem(pet.petItemStack.value, 0, 0)
+ it.context.pose().popMatrix()
- it.context.matrices.popMatrix()
+ it.context.pose().popMatrix()
}
}
@@ -404,7 +404,7 @@ object PetParser {
}
@OptIn(ExpensiveItemCacheApi::class)
- fun parseTabWidget(lines: List<Text>): ParsedPet? {
+ fun parseTabWidget(lines: List<Component>): ParsedPet? {
found.clear()
for (line in lines.reversed()) {
if (!found.containsKey("kat")) {
@@ -524,20 +524,20 @@ object PetParser {
}
data class ParsedPet(
- val name: String,
- val rarity: Rarity,
- var level: Int,
- val maxLevel: Int,
- val expLadder: ExpLadders.ExpLadder?,
- var currentExp: Double,
- var expForNextLevel: Double,
- var totalExp: Double,
- var totalExpBeforeLevel: Double,
- val expForMax: Double,
- var overflowExp: Double,
- var petItem: String,
- var petItemStack: Lazy<ItemStack>,
- var isComplete: Boolean
+ val name: String,
+ val rarity: Rarity,
+ var level: Int,
+ val maxLevel: Int,
+ val expLadder: ExpLadders.ExpLadder?,
+ var currentExp: Double,
+ var expForNextLevel: Double,
+ var totalExp: Double,
+ var totalExpBeforeLevel: Double,
+ val expForMax: Double,
+ var overflowExp: Double,
+ var petItem: String,
+ var petItemStack: Lazy<ItemStack>,
+ var isComplete: Boolean
) {
fun update(other: ParsedPet) {
// Update the pet data to reflect another instance (of itself)
diff --git a/src/main/kotlin/features/inventory/PriceData.kt b/src/main/kotlin/features/inventory/PriceData.kt
index 5f9268e..54802db 100644
--- a/src/main/kotlin/features/inventory/PriceData.kt
+++ b/src/main/kotlin/features/inventory/PriceData.kt
@@ -1,8 +1,8 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
-import net.minecraft.text.Text
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.network.chat.Component
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.repo.HypixelStaticData
@@ -34,25 +34,25 @@ object PriceData {
}
}
- enum class AvgLowestBin : StringIdentifiable {
+ enum class AvgLowestBin : StringRepresentable {
OFF,
ONEDAYAVGLOWESTBIN,
THREEDAYAVGLOWESTBIN,
SEVENDAYAVGLOWESTBIN;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
- fun formatPrice(label: Text, price: Double): Text {
- return Text.literal("")
+ fun formatPrice(label: Component, price: Double): Component {
+ return Component.literal("")
.yellow()
.bold()
.append(label)
.append(": ")
.append(
- Text.literal(formatCommas(price, fractionalDigits = 1))
+ Component.literal(formatCommas(price, fractionalDigits = 1))
.append(if (price != 1.0) " coins" else " coin")
.gold()
.bold()
@@ -84,7 +84,7 @@ object PriceData {
AvgLowestBin.OFF -> null
}
if (bazaarData != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
@@ -99,7 +99,7 @@ object PriceData {
)
)
} else if (lowestBin != null) {
- it.lines.add(Text.literal(""))
+ it.lines.add(Component.literal(""))
it.lines.add(multiplierText)
it.lines.add(
formatPrice(
diff --git a/src/main/kotlin/features/inventory/REIDependencyWarner.kt b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
index 9e8a4db..e508016 100644
--- a/src/main/kotlin/features/inventory/REIDependencyWarner.kt
+++ b/src/main/kotlin/features/inventory/REIDependencyWarner.kt
@@ -6,8 +6,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
import net.minecraft.SharedConstants
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.Text
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.Component
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
@@ -31,22 +31,22 @@ object REIDependencyWarner {
var sentWarning = false
fun modrinthLink(slug: String) =
- "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getGameVersion().name()}&l=fabric"
+ "https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getCurrentVersion().name()}&l=fabric"
- fun downloadButton(modName: String, modId: String, slug: String): Text {
+ fun downloadButton(modName: String, modId: String, slug: String): Component {
val alreadyDownloaded = FabricLoader.getInstance().isModLoaded(modId)
- return Text.literal(" - ")
+ return Component.literal(" - ")
.white()
- .append(Text.literal("[").aqua())
- .append(Text.translatable("firmament.download", modName)
- .styled { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
+ .append(Component.literal("[").aqua())
+ .append(Component.translatable("firmament.download", modName)
+ .withStyle { it.withClickEvent(ClickEvent.OpenUrl(URI (modrinthLink(slug)))) }
.yellow()
.also {
if (alreadyDownloaded)
- it.append(Text.translatable("firmament.download.already", modName)
+ it.append(Component.translatable("firmament.download.already", modName)
.lime())
})
- .append(Text.literal("]").aqua())
+ .append(Component.literal("]").aqua())
}
@Subscribe
@@ -60,11 +60,11 @@ object REIDependencyWarner {
delay(2.seconds)
// TODO: should we offer an automatic install that actually downloads the JARs and places them into the mod folder?
MC.sendChat(
- Text.translatable("firmament.reiwarning").red().bold().append("\n")
+ Component.translatable("firmament.reiwarning").red().bold().append("\n")
.append(downloadButton("RoughlyEnoughItems", reiModId, "rei")).append("\n")
.append(downloadButton("Architectury API", "architectury", "architectury-api")).append("\n")
.append(downloadButton("Cloth Config API", "cloth-config", "cloth-config")).append("\n")
- .append(Text.translatable("firmament.reiwarning.disable")
+ .append(Component.translatable("firmament.reiwarning.disable")
.clickCommand("/firm disablereiwarning")
.grey())
)
@@ -78,7 +78,7 @@ object REIDependencyWarner {
thenExecute {
RepoManager.TConfig.warnForMissingItemListMod = false
RepoManager.TConfig.markDirty()
- MC.sendChat(Text.translatable("firmament.reiwarning.disabled").yellow())
+ MC.sendChat(Component.translatable("firmament.reiwarning.disabled").yellow())
}
}
}
diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
index c523661..c492a75 100644
--- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt
+++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt
@@ -3,7 +3,7 @@ package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
import kotlin.math.absoluteValue
import kotlin.time.Duration.Companion.milliseconds
-import net.minecraft.client.util.InputUtil
+import com.mojang.blaze3d.platform.InputConstants
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.TimeMark
import moe.nea.firmament.util.assertNotNullOr
@@ -43,9 +43,9 @@ object SaveCursorPosition {
(lastPosition.middle.first - middleX).absoluteValue < 1 &&
(lastPosition.middle.second - middleY).absoluteValue < 1
) {
- InputUtil.setCursorParameters(
+ InputConstants.grabOrReleaseMouse(
MC.window,
- InputUtil.GLFW_CURSOR_NORMAL,
+ InputConstants.CURSOR_NORMAL,
lastPosition.cursor.first,
lastPosition.cursor.second
)
diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt
index 10c58cb..09afe80 100644
--- a/src/main/kotlin/features/inventory/SlotLocking.kt
+++ b/src/main/kotlin/features/inventory/SlotLocking.kt
@@ -16,17 +16,17 @@ import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.int
import kotlinx.serialization.serializer
-import net.minecraft.client.gl.RenderPipelines
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-import net.minecraft.client.gui.screen.ingame.InventoryScreen
-import net.minecraft.entity.player.PlayerInventory
-import net.minecraft.item.ItemStack
-import net.minecraft.screen.GenericContainerScreenHandler
-import net.minecraft.screen.PlayerScreenHandler
-import net.minecraft.screen.slot.Slot
-import net.minecraft.screen.slot.SlotActionType
-import net.minecraft.util.Identifier
-import net.minecraft.util.StringIdentifiable
+import net.minecraft.client.renderer.RenderPipelines
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
+import net.minecraft.client.gui.screens.inventory.InventoryScreen
+import net.minecraft.world.entity.player.Inventory
+import net.minecraft.world.item.ItemStack
+import net.minecraft.world.inventory.ChestMenu
+import net.minecraft.world.inventory.InventoryMenu
+import net.minecraft.world.inventory.Slot
+import net.minecraft.world.inventory.ClickType
+import net.minecraft.resources.ResourceLocation
+import net.minecraft.util.StringRepresentable
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ClientInitEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
@@ -157,12 +157,12 @@ object SlotLocking {
val allowDroppingInDungeons by toggle("drop-in-dungeons") { true }
}
- enum class SlotRenderLinesMode : StringIdentifiable {
+ enum class SlotRenderLinesMode : StringRepresentable {
EVERYTHING,
ONLY_BOXES,
NOTHING;
- override fun asString(): String {
+ override fun getSerializedName(): String {
return name
}
}
@@ -175,25 +175,25 @@ object SlotLocking {
val lockedSlots
get() = currentWorldData?.lockedSlots
- fun isSalvageScreen(screen: HandledScreen<*>?): Boolean {
+ fun isSalvageScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
return screen.title.unformattedString.contains("Salvage Item")
}
- fun isTradeScreen(screen: HandledScreen<*>?): Boolean {
+ fun isTradeScreen(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val middlePane = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val middlePane = handler.container.getItem(handler.container.containerSize - 5)
if (middlePane == null) return false
return middlePane.displayNameAccordingToNbt?.unformattedString == "⇦ Your stuff"
}
- fun isNpcShop(screen: HandledScreen<*>?): Boolean {
+ fun isNpcShop(screen: AbstractContainerScreen<*>?): Boolean {
if (screen == null) return false
- val handler = screen.screenHandler as? GenericContainerScreenHandler ?: return false
- if (handler.inventory.size() < 9) return false
- val sellItem = handler.inventory.getStack(handler.inventory.size() - 5)
+ val handler = screen.menu as? ChestMenu ?: return false
+ if (handler.container.containerSize < 9) return false
+ val sellItem = handler.container.getItem(handler.container.containerSize - 5)
if (sellItem == null) return false
if (sellItem.displayNameAccordingToNbt.unformattedString == "Sell Item") return true
val lore = sellItem.loreAccordingToNbt
@@ -203,15 +203,15 @@ object SlotLocking {
@Subscribe
fun onSalvageProtect(event: IsSlotProtectedEvent) {
if (event.slot == null) return
- if (!event.slot.hasStack()) return
- if (event.slot.stack.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
- val inv = event.slot.inventory
+ if (!event.slot.hasItem()) return
+ if (event.slot.item.displayNameAccordingToNbt.unformattedString != "Salvage Items") return
+ val inv = event.slot.container
var anyBlocked = false
- for (i in 0 until event.slot.index) {
- val stack = inv.getStack(i)
+ for (i in 0 until event.slot.containerSlot) {
+ val stack = inv.getItem(i)
if (IsSlotProtectedEvent.shouldBlockInteraction(
null,
- SlotActionType.THROW,
+ ClickType.THROW,
IsSlotProtectedEvent.MoveOrigin.SALVAGE,
stack
)
@@ -225,15 +225,15 @@ object SlotLocking {
@Subscribe
fun onProtectUuidItems(event: IsSlotProtectedEvent) {
- val doesNotDeleteItem = event.actionType == SlotActionType.SWAP
- || event.actionType == SlotActionType.PICKUP
- || event.actionType == SlotActionType.QUICK_MOVE
- || event.actionType == SlotActionType.QUICK_CRAFT
- || event.actionType == SlotActionType.CLONE
- || event.actionType == SlotActionType.PICKUP_ALL
+ val doesNotDeleteItem = event.actionType == ClickType.SWAP
+ || event.actionType == ClickType.PICKUP
+ || event.actionType == ClickType.QUICK_MOVE
+ || event.actionType == ClickType.QUICK_CRAFT
+ || event.actionType == ClickType.CLONE
+ || event.actionType == ClickType.PICKUP_ALL
val isSellOrTradeScreen =
isNpcShop(MC.handledScreen) || isTradeScreen(MC.handledScreen) || isSalvageScreen(MC.handledScreen)
- if ((!isSellOrTradeScreen || event.slot?.inventory !is PlayerInventory)
+ if ((!isSellOrTradeScreen || event.slot?.container !is Inventory)
&& doesNotDeleteItem
) return
val stack = event.itemStack ?: return
@@ -253,7 +253,7 @@ object SlotLocking {
@Subscribe
fun onProtectSlot(it: IsSlotProtectedEvent) {
- if (it.slot != null && it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())) {
+ if (it.slot != null && it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())) {
it.protect()
}
}
@@ -275,14 +275,14 @@ object SlotLocking {
fun onQuickMoveBoundSlot(it: IsSlotProtectedEvent) {
val boundSlots = currentWorldData?.boundSlots ?: BoundSlots()
val isValidAction =
- it.actionType == SlotActionType.QUICK_MOVE || (it.actionType == SlotActionType.PICKUP && !TConfig.slotBindRequireShift)
+ it.actionType == ClickType.QUICK_MOVE || (it.actionType == ClickType.PICKUP && !TConfig.slotBindRequireShift)
if (!isValidAction) return
- val handler = MC.handledScreen?.screenHandler ?: return
- if (TConfig.slotBindOnlyInInv && handler !is PlayerScreenHandler)
+ val handler = MC.handledScreen?.menu ?: return
+ if (TConfig.slotBindOnlyInInv && handler !is InventoryMenu)
return
val slot = it.slot
- if (slot != null && it.slot.inventory is PlayerInventory) {
- val matchingSlots = boundSlots.findMatchingSlots(slot.index)