SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
393 stars 211 forks source link

Logged slot transactions without event #3680

Open Faithcaio opened 2 years ago

Faithcaio commented 2 years ago

In API8/9 the PhaseTracker is currently not capturing a few inventory changes causing the following warning and stacktrace

[Server thread/WARN] [sponge]: Logged slot transactions without event! 1 net.minecraft.world.inventory.InventoryMenu
java.lang.Exception: 
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerBasedTransaction.generateEvent(ContainerBasedTransaction.java:167) ~[?:?]
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction.generateEvent(ContainerSlotTransaction.java:34) ~[?:?]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.generateEventForTransaction(TransactionalCaptureSupplier.java:298) ~[?:?]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.batchTransactions(TransactionalCaptureSupplier.java:235) ~[?:?]
...

For Inventory events to fire we need to start a Transaction for it.

A few reported cases: https://github.com/SpongePowered/Sponge/issues/3653 (keep inventory)

[Server thread/WARN] [sponge]: Logged slot transactions without event! 1 net.minecraft.world.inventory.InventoryMenu
java.lang.Exception: 
        at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerBasedTransaction.generateEvent(ContainerBasedTransaction.java:167) ~[ContainerBasedTransaction.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction.generateEvent(ContainerSlotTransaction.java:34) ~[ContainerSlotTransaction.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.generateEventForTransaction(TransactionalCaptureSupplier.java:298) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.batchTransactions(TransactionalCaptureSupplier.java:235) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.processTransactions(TransactionalCaptureSupplier.java:172) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.TrackingUtil.processBlockCaptures(TrackingUtil.java:450) ~[TrackingUtil.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.phase.packet.PacketState.unwind(PacketState.java:69) ~[PacketState.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.phase.packet.PacketState.unwind(PacketState.java:48) ~[PacketState.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.PhaseTracker.completePhase(PhaseTracker.java:403) ~[PhaseTracker.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.PhaseContext.close(PhaseContext.java:325) ~[PhaseContext.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.phase.packet.PacketContext.close(PacketContext.java:139) ~[PacketContext.class:1.16.5-8.0.0-RC1095]
        at org.spongepowered.common.event.tracking.phase.packet.PacketPhaseUtil.onProcessPacket(PacketPhaseUtil.java:263) ~[PacketPhaseUtil.class:1.16.5-8.0.0-RC1095]
        at net.minecraft.network.protocol.PacketUtils.mde5f064$lambda$tracker$redirectProcessPacket$0$0(SourceFile:552) ~[?:?]
        at net.minecraft.server.TickTask.run(SourceFile:18) ~[?:?]

https://github.com/SpongePowered/Sponge/issues/3672 (use map)

[28Apr2022 16:02:40] [Server thread/WARN]: Logged slot transactions without event! 1 net.minecraft.world.inventory.InventoryMenu
java.lang.Exception: 
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerBasedTransaction.generateEvent(ContainerBasedTransaction.java:167) ~[ContainerBasedTransaction.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction.generateEvent(ContainerSlotTransaction.java:34) ~[ContainerSlotTransaction.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.generateEventForTransaction(TransactionalCaptureSupplier.java:298) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.batchTransactions(TransactionalCaptureSupplier.java:235) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.processTransactions(TransactionalCaptureSupplier.java:172) ~[TransactionalCaptureSupplier.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.TrackingUtil.processBlockCaptures(TrackingUtil.java:450) ~[TrackingUtil.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.phase.packet.player.UseItemPacketState.unwind(UseItemPacketState.java:123) ~[UseItemPacketState.class:1.16.5-8.0.0-RC1112]
    at org.spongepowered.common.event.tracking.phase.packet.player.UseItemPacketState.unwind(UseItemPacketState.java:59) ~[UseItemPacketState.class:1.16.5-8.0.0-RC1112]

https://github.com/SpongePowered/Sponge/issues/3527 (tinkers construct - inventory interactions?)

(create mod - filter item)

java.lang.Exception: org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.logTransaction(TransactionalCaptureSupplier.java:134) ~[spongeforge:1.16.5-36.2.5-8.0.0-RC1100]
    at org.spongepowered.common.event.tracking.context.transaction.TransactionSink.logSlotTransaction(TransactionSink.java:315) ~[spongeforge:1.16.5-36.2.5-8.0.0-RC1100]
    at net.minecraft.inventory.container.Container.impl$capture(Container.java:1458) ~[?:?]
    at net.minecraft.inventory.container.Container.bridge$detectAndSendChanges(Container.java:1399) ~[?:?]
    at net.minecraft.inventory.container.Container.handler$zdk000$impl$broadcastChangesWithTransactions(Container.java:1365) ~[?:?]
    at net.minecraft.inventory.container.Container.func_75142_b(Container.java) ~[?:?]
    at net.minecraft.inventory.container.Container.func_75132_a(Container.java:99) ~[?:?]
    at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:232) ~[forge:?]
    at com.simibubi.create.content.logistics.item.filter.FilterItem.func_77659_a(FilterItem.java:149) ~[create:mc1.16.5_v0.3.2g]
    at com.simibubi.create.content.logistics.item.filter.FilterItem.func_195939_a(FilterItem.java:70) ~[create:mc1.16.5_v0.3.2g]
    at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:644) ~[forge:?]
...

(ae2 - open ae2 drive gui)

[20:38:03] [Server thread/WARN] [sponge/]: Logged transaction without event transaction!
java.lang.Exception: org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction
        at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.logTransaction(TransactionalCaptureSupplier.java:134) ~[spongeforge:1.16.5-36.2.5-8.0.0-RC1100] {re:mixin,re:classloading}
        at org.spongepowered.common.event.tracking.context.transaction.TransactionSink.logSlotTransaction(TransactionSink.java:315) ~[spongeforge:1.16.5-36.2.5-8.0.0-RC1100] {re:mixin,re:classloading}
        at net.minecraft.inventory.container.Container.impl$capture(Container.java:1458) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.sponge.inventory.json:api.TraitMixin_Carried_Inventory_API,pl:mixin:APP:mixins.sponge.inventory.json:event.world.inventory.AbstractContainerMenuMixin_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Adapter_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Bridge_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Fabric_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Menu_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:api.inventory.container.ContainerMixin_Inventory_API,pl:mixin:APP:mixins.sponge.accessors.json:world.inventory.AbstractContainerMenuAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
        at net.minecraft.inventory.container.Container.bridge$detectAndSendChanges(Container.java:1399) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.sponge.inventory.json:api.TraitMixin_Carried_Inventory_API,pl:mixin:APP:mixins.sponge.inventory.json:event.world.inventory.AbstractContainerMenuMixin_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Adapter_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Bridge_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Fabric_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Menu_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:api.inventory.container.ContainerMixin_Inventory_API,pl:mixin:APP:mixins.sponge.accessors.json:world.inventory.AbstractContainerMenuAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
        at net.minecraft.inventory.container.Container.handler$zzh000$impl$broadcastChangesWithTransactions(Container.java:1365) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.sponge.inventory.json:api.TraitMixin_Carried_Inventory_API,pl:mixin:APP:mixins.sponge.inventory.json:event.world.inventory.AbstractContainerMenuMixin_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Adapter_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Bridge_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Fabric_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Menu_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:api.inventory.container.ContainerMixin_Inventory_API,pl:mixin:APP:mixins.sponge.accessors.json:world.inventory.AbstractContainerMenuAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
        at net.minecraft.inventory.container.Container.func_75142_b(Container.java) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.sponge.inventory.json:api.TraitMixin_Carried_Inventory_API,pl:mixin:APP:mixins.sponge.inventory.json:event.world.inventory.AbstractContainerMenuMixin_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Adapter_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Bridge_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Fabric_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Menu_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:api.inventory.container.ContainerMixin_Inventory_API,pl:mixin:APP:mixins.sponge.accessors.json:world.inventory.AbstractContainerMenuAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
        at appeng.container.AEBaseContainer.func_75142_b(AEBaseContainer.java:249) ~[appliedenergistics2:8.4.7] {re:classloading}
        at net.minecraft.inventory.container.Container.func_75132_a(Container.java:99) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:mixins.sponge.inventory.json:api.TraitMixin_Carried_Inventory_API,pl:mixin:APP:mixins.sponge.inventory.json:event.world.inventory.AbstractContainerMenuMixin_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Adapter_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Bridge_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Fabric_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:impl.world.inventory.AbstractContainerMenuMixin_Menu_Inventory,pl:mixin:APP:mixins.sponge.inventory.json:api.inventory.container.ContainerMixin_Inventory_API,pl:mixin:APP:mixins.sponge.accessors.json:world.inventory.AbstractContainerMenuAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
        at appeng.container.AEBaseContainer.func_75132_a(AEBaseContainer.java:706) ~[appliedenergistics2:8.4.7] {re:classloading}
        at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:232) ~[forge:?] {re:classloading}
        at appeng.container.implementations.ContainerTypeBuilder.open(ContainerTypeBuilder.java:175) ~[appliedenergistics2:8.4.7] {re:classloading}
        at appeng.container.ContainerOpener.openContainer(ContainerOpener.java:50) ~[appliedenergistics2:8.4.7] {re:classloading}
        at appeng.block.storage.DriveBlock.onActivated(DriveBlock.java:55) ~[appliedenergistics2:8.4.7] {re:classloading}
        at appeng.block.AEBaseTileBlock.func_225533_a_(AEBaseTileBlock.java:255) ~[appliedenergistics2:8.4.7] {re:classloading}
        at net.minecraft.block.AbstractBlock$AbstractBlockState.func_227031_a_(AbstractBlock.java:640) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:mixins.sponge.api.json:minecraft.world.level.block.state.BlockBehaviour_BlockStateBaseMixin_API,pl:mixin:A,pl:runtimedistcleaner:A}
        at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:2133) ~[?:?] {re:mixin,re:computing_frames,re:classloading,pl:mixin:APP:mixins.sponge.accessors.json:server.level.ServerPlayerGameModeAccessor,pl:mixin:APP:mixins.spongeforge.tracker.json:server.level.ServerPlayerGameModeMixin_Forge_Tracker,pl:mixin:APP:mixins.sponge.core.json:server.level.ServerPlayerGameModeMixin,pl:mixin:APP:mixins.sponge.tracker.json:server.level.ServerPlayerGameModeMixin_Tracker,pl:mixin:A}
        at net.minecraft.network.play.ServerPlayNetHandler.redirect$zcg000$tracker$checkState(ServerPlayNetHandler.java:3684) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:mixins.sponge.inventory.json:event.server.network.ServerGamePacketListenerImplMixin_Inventory,pl:mixin:APP:mixins.spongeforge.core.json:server.network.ServerGamePacketListenerImplMixin_Forge,pl:mixin:APP:mixins.sponge.api.json:minecraft.server.network.ServerGamePacketListenerImplMixin_API,pl:mixin:APP:mixins.sponge.core.json:server.network.ServerGamePacketListenerImplMixin,pl:mixin:APP:mixins.sponge.tracker.json:server.network.ServerGamePacketListenerImplMixin_Tracker,pl:mixin:A}
        at net.minecraft.network.play.ServerPlayNetHandler.func_184337_a(ServerPlayNetHandler.java:958) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:mixins.sponge.inventory.json:event.server.network.ServerGamePacketListenerImplMixin_Inventory,pl:mixin:APP:mixins.spongeforge.core.json:server.network.ServerGamePacketListenerImplMixin_Forge,pl:mixin:APP:mixins.sponge.api.json:minecraft.server.network.ServerGamePacketListenerImplMixin_API,pl:mixin:APP:mixins.sponge.core.json:server.network.ServerGamePacketListenerImplMixin,pl:mixin:APP:mixins.sponge.tracker.json:server.network.ServerGamePacketListenerImplMixin_Tracker,pl:mixin:A}
        at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.func_148833_a(SourceFile:36) ~[?:?] {re:classloading}
SettingDust commented 2 years ago

Chest to Hopper minecart. (or any other transaction not initiated by player but while player is viewing menu)

[19:13:39] [Server thread/WARN] (sponge) Logged slot transactions without event! 1 net.minecraft.world.inventory.ChestMenu
java.lang.Exception: 
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerBasedTransaction.generateEvent(ContainerBasedTransaction.java:167)
    at org.spongepowered.common.event.tracking.context.transaction.inventory.ContainerSlotTransaction.generateEvent(ContainerSlotTransaction.java:34)
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.generateEventForTransaction(TransactionalCaptureSupplier.java:298)
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.batchTransactions(TransactionalCaptureSupplier.java:251)
    at org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier.processTransactions(TransactionalCaptureSupplier.java:172)
    at org.spongepowered.common.event.tracking.TrackingUtil.processBlockCaptures(TrackingUtil.java:450)
    at org.spongepowered.common.event.tracking.phase.tick.EntityTickPhaseState.unwind(EntityTickPhaseState.java:79)
    at org.spongepowered.common.event.tracking.phase.tick.EntityTickPhaseState.unwind(EntityTickPhaseState.java:56)
    at org.spongepowered.common.event.tracking.PhaseTracker.completePhase(PhaseTracker.java:403)
    at org.spongepowered.common.event.tracking.PhaseContext.close(PhaseContext.java:325)
    at org.spongepowered.common.event.tracking.TrackingUtil.tickEntity(TrackingUtil.java:142)
    at net.minecraft.server.level.ServerLevel.redirect$zcd000$tracker$wrapNormalEntityTick(ServerLevel.java:3792)
    at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:411)
    at net.minecraft.server.MinecraftServer.redirect$zca000$tracker$wrapWorldTick(MinecraftServer.java:4292)
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:871)
    at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:312)
    at net.minecraft.server.MinecraftServer.redirect$zca000$tracker$wrapUpdateTimeLightAndEntities(MinecraftServer.java:4274)
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:811)
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:670)
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:257)
    at java.base/java.lang.Thread.run(Thread.java:833)
[19:13:39] [Server thread/WARN] (sponge) SlotTransaction{slot=SlotAdapter[ordinal=0], original=SpongeItemStackSnapshot{itemType=minecraft:chest, quantity=1}, default=SpongeItemStackSnapshot{itemType=minecraft:air, quantity=0}, custom=Optional.empty, valid=true}
Faithcaio commented 2 years ago

https://github.com/SpongePowered/Sponge/commit/6ebd3ea977f6c24ae44f5e11edca9d0e32051801 fixes this for player respawn and looking into hopper or hopper-fed inventories.

Yeregorix commented 2 years ago

A plugin modifying an open inventory.

Code to reproduce:

Inventory inv = ViewableInventory.builder().type(ContainerTypes.GENERIC_9X6).completeStructure().plugin(plugin).build();
player.openInventory(inv);
inv.set(0, ItemStack.of(ItemTypes.STONE));

Logs: https://pastebin.com/UTD9z24f SpongeVanilla 8.1.0-RC1175

Faithcaio commented 2 years ago

modded: CuriosAPI https://gist.github.com/SawFowl/660669b4ee9e698c305dc00d31d2a01e see https://github.com/SpongePowered/Sponge/issues/3762

Inscrutable commented 1 year ago

I recently tried with spongeforge-1.16.5-36.2.5-8.1.0-RC1313-universal, and the latest Tinker's Construct for 1.16.5. Oddly, the only time this error came up was when I applied a hopper to a chest (both vanilla MC items). None of the TiC inventories gave me any error spam. Just a data point. Forge version 36.2.39, TConstruct-1.16.5-3.3.4.335 and Mantle-1.16.5-1.6.157.

mosemister commented 1 year ago

Context for the above mention (just to keep it in one)

Sponge vanilla -> Slot#set(ItemStack)

This could probably be fixed with Yeregorix post above at the same time