Make slots appear to mods at "proper" positions

This commit is contained in:
DBotThePony 2022-10-12 21:45:16 +07:00
parent e3cc740a93
commit b501efc515
Signed by: DBot
GPG Key ID: DCC23B5715498507
5 changed files with 24 additions and 0 deletions

View File

@ -186,6 +186,7 @@ dependencies {
val cosmetic_armor_reworked_version: String by project val cosmetic_armor_reworked_version: String by project
val jade_id: String by project val jade_id: String by project
val worldedit_fileid: String by project val worldedit_fileid: String by project
val more_overlays_version: String by project
implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${mc_version}-${curios_version}")) implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${mc_version}-${curios_version}"))
compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${mc_version}-${cosmetic_armor_reworked_version}")) compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${mc_version}-${cosmetic_armor_reworked_version}"))
@ -197,6 +198,7 @@ dependencies {
runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}"))
runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}"))
runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}"))
implementation(fg.deobf("mekanism:Mekanism:${mc_version}-${mekanism_version}:all")) implementation(fg.deobf("mekanism:Mekanism:${mc_version}-${mekanism_version}:all"))
} }
@ -310,6 +312,7 @@ repositories {
includeGroup("yalter.mousetweaks") includeGroup("yalter.mousetweaks")
includeGroup("mekanism") includeGroup("mekanism")
includeGroup("lain.mods.cos") includeGroup("lain.mods.cos")
includeGroup("at.ridgo8.moreoverlays")
} }
} }

View File

@ -23,6 +23,7 @@ curios_version=5.1.1.0
cosmetic_armor_reworked_version=v1 cosmetic_armor_reworked_version=v1
jade_id=4010505 jade_id=4010505
worldedit_fileid=3922622 worldedit_fileid=3922622
more_overlays_version=1.21.3-mc1.19
kotlin_for_forge_version=3.1.0 kotlin_for_forge_version=3.1.0
kotlin_version=1.6.10 kotlin_version=1.6.10

View File

@ -56,6 +56,13 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
val quickCraftingType get() = quickCraftingType val quickCraftingType get() = quickCraftingType
val isQuickCrafting get() = isQuickCrafting val isQuickCrafting get() = isQuickCrafting
init {
for (slot in menu.slots) {
slot.x = Int.MAX_VALUE
slot.y = Int.MAX_VALUE
}
}
private val inventorySlotsRows = Int2ObjectAVLTreeMap<EditablePanel<MatteryScreen<*>>>() private val inventorySlotsRows = Int2ObjectAVLTreeMap<EditablePanel<MatteryScreen<*>>>()
private lateinit var slotListCanvas: EditablePanel<MatteryScreen<*>> private lateinit var slotListCanvas: EditablePanel<MatteryScreen<*>>
private lateinit var inventoryScrollbar: DiscreteScrollBarPanel<MatteryScreen<*>> private lateinit var inventoryScrollbar: DiscreteScrollBarPanel<MatteryScreen<*>>

View File

@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.client.render.drawRect
import ru.dbotthepony.mc.otm.client.render.setDrawColor import ru.dbotthepony.mc.otm.client.render.setDrawColor
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import javax.annotation.Nonnull import javax.annotation.Nonnull
import kotlin.math.roundToInt
open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads constructor( open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads constructor(
screen: S, screen: S,
@ -47,7 +48,16 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
override val itemStack: ItemStack override val itemStack: ItemStack
get() = slot.item get() = slot.item
override fun visibilityChanges(new: Boolean, old: Boolean) {
if (!new) {
slot.x = Int.MAX_VALUE
slot.y = Int.MAX_VALUE
}
}
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
slot.x = absoluteX.roundToInt() - screen.guiLeft
slot.y = absoluteY.roundToInt() - screen.guiTop
renderSlotBackground(stack, mouseX, mouseY, partialTick) renderSlotBackground(stack, mouseX, mouseY, partialTick)
var itemstack = slot.item var itemstack = slot.item

View File

@ -76,3 +76,6 @@ public com.mojang.math.Matrix3f f_8139_ # m12
public com.mojang.math.Matrix3f f_8140_ # m20 public com.mojang.math.Matrix3f f_8140_ # m20
public com.mojang.math.Matrix3f f_8141_ # m21 public com.mojang.math.Matrix3f f_8141_ # m21
public com.mojang.math.Matrix3f f_8142_ # m22 public com.mojang.math.Matrix3f f_8142_ # m22
public-f net.minecraft.world.inventory.Slot f_40220_ # x
public-f net.minecraft.world.inventory.Slot f_40221_ # y