Make use of Curios' SlotModifiersUpdatedEvent
This commit is contained in:
parent
3c61a03fd8
commit
9cfd1e2119
@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer;
|
||||
import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer;
|
||||
import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer;
|
||||
import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt;
|
||||
import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt;
|
||||
import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt;
|
||||
import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt;
|
||||
import ru.dbotthepony.mc.otm.config.AndroidConfig;
|
||||
@ -53,6 +54,7 @@ import ru.dbotthepony.mc.otm.network.*;
|
||||
import ru.dbotthepony.mc.otm.registry.*;
|
||||
import ru.dbotthepony.mc.otm.storage.*;
|
||||
import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger;
|
||||
import top.theillusivec4.curios.api.CuriosApi;
|
||||
|
||||
import static net.minecraftforge.common.MinecraftForge.EVENT_BUS;
|
||||
|
||||
@ -199,6 +201,10 @@ public final class OverdriveThatMatters {
|
||||
EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities);
|
||||
}
|
||||
|
||||
if (ModList.get().isLoaded(CuriosApi.MODID)) {
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, CuriosCompatKt::onCuriosSlotModifiersUpdated);
|
||||
}
|
||||
|
||||
if (AdAstraCompatKt.isAdAstraLoaded()) {
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onDamageEvent);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onMatteryTick);
|
||||
|
@ -230,6 +230,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
private var _exoPackMenu: ExoPackInventoryMenu? = null
|
||||
set(value) {
|
||||
if (field == ply.containerMenu) { ply.closeContainer() }
|
||||
field?.removed(ply)
|
||||
field = value
|
||||
}
|
||||
|
||||
@ -245,6 +246,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
return _exoPackMenu!!
|
||||
}
|
||||
|
||||
fun recreateExoPackMenu() {
|
||||
_exoPackMenu = ExoPackInventoryMenu(this)
|
||||
}
|
||||
|
||||
private var shouldSendIteration = false
|
||||
|
||||
/**
|
||||
@ -1160,8 +1165,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
}
|
||||
|
||||
fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) {
|
||||
event.entity.getCapability(MatteryCapability.MATTERY_PLAYER)
|
||||
.ifPresentK { it.invalidateNetworkState() }
|
||||
event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
it.invalidateNetworkState()
|
||||
|
||||
onceServer(20) {
|
||||
it.recreateExoPackMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onPlayerDeath(event: LivingDeathEvent) {
|
||||
@ -1215,6 +1225,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
it.deserializeNBT(original.serializeNBT())
|
||||
it.invalidateNetworkState()
|
||||
event.original.invalidateCaps()
|
||||
|
||||
if (SERVER_IS_LIVE) {
|
||||
onceServer(20) {
|
||||
it.recreateExoPackMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const val SLEEP_TICKS_LIMIT = 80
|
||||
|
@ -6,12 +6,14 @@ import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.fml.ModList
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.container.awareStream
|
||||
import ru.dbotthepony.mc.otm.container.stream
|
||||
import ru.dbotthepony.mc.otm.core.collect.AwareItemStack
|
||||
import ru.dbotthepony.mc.otm.core.orNull
|
||||
import ru.dbotthepony.mc.otm.menu.PlayerSlot
|
||||
import top.theillusivec4.curios.api.CuriosApi
|
||||
import top.theillusivec4.curios.api.event.SlotModifiersUpdatedEvent
|
||||
import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot
|
||||
import top.theillusivec4.curios.common.inventory.CurioSlot
|
||||
import java.util.*
|
||||
@ -21,6 +23,11 @@ val isCuriosLoaded by lazy {
|
||||
ModList.get().isLoaded(CuriosApi.MODID)
|
||||
}
|
||||
|
||||
fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) {
|
||||
check(isCuriosLoaded) { "Curios is not loaded!" }
|
||||
event.entity.matteryPlayer?.recreateExoPackMenu()
|
||||
}
|
||||
|
||||
private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
||||
val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user