cosmetic armor streams
This commit is contained in:
parent
3d8035c977
commit
0f173922a5
@ -9,6 +9,9 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider
|
||||
import net.minecraftforge.common.util.LazyOptional
|
||||
import net.minecraftforge.energy.IEnergyStorage
|
||||
import net.minecraftforge.fml.ModList
|
||||
import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorAwareStream
|
||||
import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorStream
|
||||
import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded
|
||||
import ru.dbotthepony.mc.otm.compat.curios.curiosAwareStream
|
||||
import ru.dbotthepony.mc.otm.compat.curios.curiosStream
|
||||
import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded
|
||||
@ -173,6 +176,10 @@ fun Player.itemsStream(includeCosmetics: Boolean = true): Stream<out ItemStack>
|
||||
streams.add(curiosStream(includeCosmetics))
|
||||
}
|
||||
|
||||
if (includeCosmetics && isCosmeticArmorLoaded) {
|
||||
streams.add(cosmeticArmorStream())
|
||||
}
|
||||
|
||||
return Streams.concat(*streams.toTypedArray())
|
||||
}
|
||||
|
||||
@ -202,7 +209,7 @@ fun Player.allItemsStream(includeCosmetics: Boolean = true): Stream<out ItemStac
|
||||
*
|
||||
* Contains all items that player might carry
|
||||
*/
|
||||
fun Player.awareItemsStream(includeCosmetics: Boolean = true): Stream<out AwareItemStack> {
|
||||
fun Player.awareItemsStream(includeCosmetics: Boolean = false): Stream<out AwareItemStack> {
|
||||
val streams = LinkedList<Stream<out AwareItemStack>>()
|
||||
streams.add(inventory.awareStream())
|
||||
|
||||
@ -216,6 +223,10 @@ fun Player.awareItemsStream(includeCosmetics: Boolean = true): Stream<out AwareI
|
||||
streams.add(curiosAwareStream(includeCosmetics))
|
||||
}
|
||||
|
||||
if (includeCosmetics && isCosmeticArmorLoaded) {
|
||||
streams.add(cosmeticArmorAwareStream())
|
||||
}
|
||||
|
||||
return Streams.concat(*streams.toTypedArray())
|
||||
}
|
||||
|
||||
@ -224,7 +235,7 @@ fun Player.awareItemsStream(includeCosmetics: Boolean = true): Stream<out AwareI
|
||||
*
|
||||
* Contains all items that player might see/access ([itemsStream] + open container's items)
|
||||
*/
|
||||
fun Player.awareAllItemsStream(includeCosmetics: Boolean = true): Stream<out AwareItemStack> {
|
||||
fun Player.awareAllItemsStream(includeCosmetics: Boolean = false): Stream<out AwareItemStack> {
|
||||
if (containerMenu == inventoryMenu || containerMenu == matteryPlayer?.exoSuitMenu) {
|
||||
return awareItemsStream(includeCosmetics)
|
||||
}
|
||||
|
@ -25,7 +25,11 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.RectangleButtonPanel
|
||||
import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE
|
||||
import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE
|
||||
import ru.dbotthepony.mc.otm.container.awareStream
|
||||
import ru.dbotthepony.mc.otm.container.stream
|
||||
import ru.dbotthepony.mc.otm.core.AwareItemStack
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
import java.util.stream.Stream
|
||||
|
||||
val isCosmeticArmorLoaded by lazy {
|
||||
ModList.get().isLoaded("cosmeticarmorreworked")
|
||||
@ -65,6 +69,46 @@ private class CosmeticSlot(container: Container, private val slot: EquipmentSlot
|
||||
}
|
||||
}
|
||||
|
||||
fun Player.cosmeticArmorStream(): Stream<out ItemStack> {
|
||||
if (!isCosmeticArmorLoaded) {
|
||||
return Stream.empty()
|
||||
}
|
||||
|
||||
return cosmeticArmorStreamImpl()
|
||||
}
|
||||
|
||||
private fun Player.cosmeticArmorStreamImpl(): Stream<out ItemStack> {
|
||||
val manager = ModObjects.invMan ?: return Stream.empty()
|
||||
|
||||
val container = if (this !is ServerPlayer) {
|
||||
manager.getCosArmorInventoryClient(uuid)
|
||||
} else {
|
||||
manager.getCosArmorInventory(uuid)
|
||||
}
|
||||
|
||||
return (container as Container).stream()
|
||||
}
|
||||
|
||||
fun Player.cosmeticArmorAwareStream(): Stream<out AwareItemStack> {
|
||||
if (!isCosmeticArmorLoaded) {
|
||||
return Stream.empty()
|
||||
}
|
||||
|
||||
return cosmeticArmorAwareStreamImpl()
|
||||
}
|
||||
|
||||
private fun Player.cosmeticArmorAwareStreamImpl(): Stream<out AwareItemStack> {
|
||||
val manager = ModObjects.invMan ?: return Stream.empty()
|
||||
|
||||
val container = if (this !is ServerPlayer) {
|
||||
manager.getCosArmorInventoryClient(uuid)
|
||||
} else {
|
||||
manager.getCosArmorInventory(uuid)
|
||||
}
|
||||
|
||||
return (container as Container).awareStream()
|
||||
}
|
||||
|
||||
private val Player.cosmeticArmorSlotsImpl: Map<EquipmentSlot, Slot>? get() {
|
||||
val manager = ModObjects.invMan ?: return null
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user