feat: Add item rarities into all storage overlay pages
This commit is contained in:
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen
|
|||||||
import net.minecraft.screen.slot.Slot
|
import net.minecraft.screen.slot.Slot
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import net.minecraft.util.Identifier
|
import net.minecraft.util.Identifier
|
||||||
|
import moe.nea.firmament.events.SlotRenderEvents
|
||||||
import moe.nea.firmament.gui.EmptyComponent
|
import moe.nea.firmament.gui.EmptyComponent
|
||||||
import moe.nea.firmament.gui.FirmButtonComponent
|
import moe.nea.firmament.gui.FirmButtonComponent
|
||||||
import moe.nea.firmament.util.MC
|
import moe.nea.firmament.util.MC
|
||||||
@@ -21,6 +22,7 @@ import moe.nea.firmament.util.MoulConfigUtils.clickMCComponentInPlace
|
|||||||
import moe.nea.firmament.util.MoulConfigUtils.drawMCComponentInPlace
|
import moe.nea.firmament.util.MoulConfigUtils.drawMCComponentInPlace
|
||||||
import moe.nea.firmament.util.assertTrueOr
|
import moe.nea.firmament.util.assertTrueOr
|
||||||
import moe.nea.firmament.util.customgui.customGui
|
import moe.nea.firmament.util.customgui.customGui
|
||||||
|
import moe.nea.firmament.util.mc.FakeSlot
|
||||||
import moe.nea.firmament.util.render.drawGuiTexture
|
import moe.nea.firmament.util.render.drawGuiTexture
|
||||||
|
|
||||||
class StorageOverlayScreen : Screen(Text.literal("")) {
|
class StorageOverlayScreen : Screen(Text.literal("")) {
|
||||||
@@ -356,9 +358,12 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
|
|||||||
inv.stacks.forEachIndexed { index, stack ->
|
inv.stacks.forEachIndexed { index, stack ->
|
||||||
val slotX = (index % 9) * SLOT_SIZE + x + 1
|
val slotX = (index % 9) * SLOT_SIZE + x + 1
|
||||||
val slotY = (index / 9) * SLOT_SIZE + y + 4 + textRenderer.fontHeight + 1
|
val slotY = (index / 9) * SLOT_SIZE + y + 4 + textRenderer.fontHeight + 1
|
||||||
|
val fakeSlot = FakeSlot(stack, slotX, slotY)
|
||||||
if (slots == null) {
|
if (slots == null) {
|
||||||
|
SlotRenderEvents.Before.publish(SlotRenderEvents.Before(context, fakeSlot))
|
||||||
context.drawItem(stack, slotX, slotY)
|
context.drawItem(stack, slotX, slotY)
|
||||||
context.drawStackOverlay(textRenderer, stack, slotX, slotY)
|
context.drawStackOverlay(textRenderer, stack, slotX, slotY)
|
||||||
|
SlotRenderEvents.After.publish(SlotRenderEvents.After(context, fakeSlot))
|
||||||
} else {
|
} else {
|
||||||
val slot = slots[index]
|
val slot = slots[index]
|
||||||
slot.x = slotX - slotOffset.x
|
slot.x = slotX - slotOffset.x
|
||||||
|
|||||||
41
src/main/kotlin/util/mc/FakeInventory.kt
Normal file
41
src/main/kotlin/util/mc/FakeInventory.kt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package util.mc
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity
|
||||||
|
import net.minecraft.inventory.Inventory
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
|
||||||
|
class FakeInventory(val stack: ItemStack) : Inventory {
|
||||||
|
override fun clear() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun size(): Int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty(): Boolean {
|
||||||
|
return stack.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getStack(slot: Int): ItemStack {
|
||||||
|
require(slot == 0)
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeStack(slot: Int, amount: Int): ItemStack {
|
||||||
|
return ItemStack.EMPTY
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeStack(slot: Int): ItemStack {
|
||||||
|
return ItemStack.EMPTY
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setStack(slot: Int, stack: ItemStack?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun markDirty() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun canPlayerUse(player: PlayerEntity?): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/main/kotlin/util/mc/FakeSlot.kt
Normal file
15
src/main/kotlin/util/mc/FakeSlot.kt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package moe.nea.firmament.util.mc
|
||||||
|
|
||||||
|
import util.mc.FakeInventory
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.screen.slot.Slot
|
||||||
|
|
||||||
|
class FakeSlot(
|
||||||
|
stack: ItemStack,
|
||||||
|
x: Int,
|
||||||
|
y: Int
|
||||||
|
) : Slot(FakeInventory(stack), 0, x, y) {
|
||||||
|
init {
|
||||||
|
id = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user