diff options
Diffstat (limited to 'src/main/kotlin/util/mc/ScreenUtil.kt')
| -rw-r--r-- | src/main/kotlin/util/mc/ScreenUtil.kt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/kotlin/util/mc/ScreenUtil.kt b/src/main/kotlin/util/mc/ScreenUtil.kt index 36feb6b..4e3dbf1 100644 --- a/src/main/kotlin/util/mc/ScreenUtil.kt +++ b/src/main/kotlin/util/mc/ScreenUtil.kt @@ -1,9 +1,9 @@ package moe.nea.firmament.util.mc -import net.minecraft.client.gui.screen.Screen -import net.minecraft.client.gui.screen.ingame.HandledScreen -import net.minecraft.entity.player.PlayerInventory -import net.minecraft.screen.slot.Slot +import net.minecraft.client.gui.screens.Screen +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.Slot object ScreenUtil { private var lastScreen: Screen? = null @@ -12,15 +12,15 @@ object ScreenUtil { data class SlotIndex(val index: Int, val isPlayerInventory: Boolean) fun Screen.getSlotsByIndex(): Map<SlotIndex, Slot> { - if (this !is HandledScreen<*>) return mapOf() + if (this !is AbstractContainerScreen<*>) return mapOf() if (lastScreen === this) return slotsByIndex lastScreen = this - slotsByIndex = this.screenHandler.slots.associate { - SlotIndex(it.index, it.inventory is PlayerInventory) to it + slotsByIndex = this.menu.slots.associate { + SlotIndex(it.containerSlot, it.container is Inventory) to it } return slotsByIndex } - fun Screen.getSlotByIndex( index: Int, isPlayerInventory: Boolean): Slot? = + fun Screen.getSlotByIndex(index: Int, isPlayerInventory: Boolean): Slot? = getSlotsByIndex()[SlotIndex(index, isPlayerInventory)] } |
