Curios in exosuit inventory
right now it is without cosmetic checkbox
This commit is contained in:
parent
39f4edb857
commit
d091dca6cf
@ -182,8 +182,7 @@ dependencies {
|
||||
val mekanism_version: String by project
|
||||
val curios_version: String by project
|
||||
|
||||
compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${mc_version}-${curios_version}:api"))
|
||||
runtimeOnly(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("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
|
||||
compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
|
||||
|
@ -10,6 +10,8 @@ import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage;
|
||||
import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode;
|
||||
import ru.dbotthepony.mc.otm.graph.storage.IStorageGraphNode;
|
||||
import ru.dbotthepony.mc.otm.storage.IStorageStack;
|
||||
import top.theillusivec4.curios.api.type.capability.ICurio;
|
||||
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -49,4 +51,12 @@ public class MatteryCapability {
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public static final Capability<IStrictEnergyHandler> MEKANISM_ENERGY = CapabilityManager.get(new CapabilityToken<>() {});
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public static final Capability<ICuriosItemHandler> CURIOS_INVENTORY = CapabilityManager.get(new CapabilityToken<>() {});
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public static final Capability<ICurio> CURIOS_ITEM = CapabilityManager.get(new CapabilityToken<>() {});
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.client.render.element
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.setMousePos
|
||||
import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory
|
||||
import ru.dbotthepony.mc.otm.compat.curios.curiosSlots
|
||||
import ru.dbotthepony.mc.otm.core.maxScrollDivision
|
||||
import ru.dbotthepony.mc.otm.menu.ExoSuitInventoryMenu
|
||||
import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen
|
||||
@ -169,7 +170,31 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
moveMousePosScaled(y = movePixels)
|
||||
}
|
||||
|
||||
EffectListPanel(this, frame, menu.ply, -56f, gridHeight = 6).tick()
|
||||
var x = -4f
|
||||
|
||||
val curios = menu.ply.curiosSlots
|
||||
|
||||
if (curios.isNotEmpty()) {
|
||||
val curiosRect = BackgroundPanel.padded(this, frame, x,
|
||||
width = if (curios.stream().anyMatch { it.second != null }) AbstractSlotPanel.SIZE * 2f else AbstractSlotPanel.SIZE,
|
||||
height = curios.size * AbstractSlotPanel.SIZE)
|
||||
|
||||
x -= curiosRect.width
|
||||
curiosRect.x = x
|
||||
|
||||
for ((slot, cosmetic) in curios) {
|
||||
val row = EditablePanel(this, curiosRect, height = AbstractSlotPanel.SIZE)
|
||||
row.dock = Dock.TOP
|
||||
|
||||
SlotPanel(this, row, slot).dock = Dock.RIGHT
|
||||
|
||||
if (cosmetic != null) {
|
||||
SlotPanel(this, row, cosmetic).dock = Dock.LEFT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EffectListPanel(this, frame, menu.ply, x - 56f, gridHeight = 6).tick()
|
||||
|
||||
return frame
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package ru.dbotthepony.mc.otm.compat.curios
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraftforge.fml.ModList
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.core.orNull
|
||||
import top.theillusivec4.curios.api.CuriosApi
|
||||
import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot
|
||||
import top.theillusivec4.curios.common.inventory.CurioSlot
|
||||
|
||||
val isCuriosLoaded by lazy {
|
||||
ModList.get().isLoaded(CuriosApi.MODID)
|
||||
}
|
||||
|
||||
private fun Player.getCuriosSlotsImpl(): Collection<Pair<Slot, Slot?>> {
|
||||
val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf()
|
||||
|
||||
val result = ArrayList<Pair<Slot, Slot?>>()
|
||||
|
||||
for ((identifier, curio) in handler.curios) {
|
||||
if (curio.isVisible) {
|
||||
val stacks = curio.stacks
|
||||
|
||||
for (slot in 0 until stacks.slots) {
|
||||
val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders)
|
||||
|
||||
if (curio.hasCosmetic()) {
|
||||
val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0)
|
||||
|
||||
result.add(regular to cosmetic)
|
||||
} else {
|
||||
result.add(regular to null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* [Pair]<Regular, Cosmetic>
|
||||
*/
|
||||
val Player.curiosSlots: Collection<Pair<Slot, Slot?>> get() {
|
||||
if (!isCuriosLoaded) {
|
||||
return listOf()
|
||||
}
|
||||
|
||||
return getCuriosSlotsImpl()
|
||||
}
|
Loading…
Reference in New Issue
Block a user