Invalidate recipe caches on resources reload
This commit is contained in:
parent
c98a1573aa
commit
640aeabb07
@ -14,6 +14,8 @@ import ru.dbotthepony.mc.otm.player.android.AndroidResearchResults
|
||||
import ru.dbotthepony.mc.otm.player.android.feature.EnderTeleporterFeature
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
|
||||
import ru.dbotthepony.mc.otm.player.MatteryPlayer
|
||||
import ru.dbotthepony.mc.otm.capability.drive.DrivePool
|
||||
import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping
|
||||
@ -244,6 +246,9 @@ object OverdriveThatMatters {
|
||||
|
||||
FORGE_BUS.addListener(EventPriority.NORMAL, MStructureTags::registerVillagerTrades)
|
||||
|
||||
FORGE_BUS.addListener(EventPriority.LOWEST, PlatePressBlockEntity::onReload)
|
||||
FORGE_BUS.addListener(EventPriority.LOWEST, AbstractPoweredFurnaceBlockEntity.Companion::onReload)
|
||||
|
||||
if (isCuriosLoaded) {
|
||||
FORGE_BUS.addListener(EventPriority.NORMAL, ::onCuriosSlotModifiersUpdated)
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M
|
||||
}
|
||||
|
||||
private inner class InputSlot(container: SlottedContainer, slot: Int) : FilteredContainerSlot(container, slot) {
|
||||
// may get stalled on /reload command for up to a minute
|
||||
// shouldn't cause major issues through, since /reload is not something you frequently be executing
|
||||
val insertCache = SimpleCache<ItemStackKey, Boolean>(Duration.ofMinutes(1))
|
||||
|
||||
override fun canAutomationPlaceItem(itemStack: ItemStack): Boolean {
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.item.crafting.SmokingRecipe
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.neoforged.neoforge.capabilities.Capabilities
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent
|
||||
import ru.dbotthepony.kommons.util.getValue
|
||||
import ru.dbotthepony.kommons.util.setValue
|
||||
import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage
|
||||
@ -203,6 +204,10 @@ sealed class AbstractPoweredFurnaceBlockEntity<P : AbstractCookingRecipe, S : Ma
|
||||
companion object {
|
||||
// shared by all furnace instances, so cache should be large enough
|
||||
private val acceptableItems = SimpleCache<ItemStackKey, Boolean>(Duration.ofMinutes(1))
|
||||
|
||||
internal fun onReload(event: AddReloadListenerEvent) {
|
||||
acceptableItems.invalidateAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.SingleRecipeInput
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.neoforged.neoforge.capabilities.Capabilities
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent
|
||||
import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage
|
||||
import ru.dbotthepony.mc.otm.block.entity.JobContainer
|
||||
import ru.dbotthepony.mc.otm.block.entity.JobStatus
|
||||
@ -128,5 +129,9 @@ class PlatePressBlockEntity(
|
||||
|
||||
companion object {
|
||||
private val cache = SimpleCache<ItemStackKey, Boolean>(Duration.ofMinutes(1L))
|
||||
|
||||
internal fun onReload(event: AddReloadListenerEvent) {
|
||||
cache.invalidateAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user