PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

50M Downloads

Smart Chest crashes with Hopper Botany Pot

Venom31 opened this issue ยท 5 comments

commented

Minecraft Version

1.16.5

Forge Version

36.2.2

Mod Version

1.16.5-2.13.3--211

  • BotanyPots 7.1.23 (from Enigmatica 6 modpack)

Describe your problem, including steps to reproduce it

If you place a Hopper Botany Pot on top of a Smart Chest with something growing and configure it to pull from above, the game crashes. Reopening a save crashes instantly with the same error. See crash log here.

Any other comments?

I sped up oak sapling with time in a bottle, sapling itself was on some fertilized farmland that I can't remember the name of, and I can't check because the world is insta-crashing the game on load. So I hope that doesn't matter.

commented

Lurker here, unofficial input follows...

The Botany Pot is coded to simulate an outgoing inventory for cosmetic purposes:

The inventory declaration:

    /**
     * A useless inventory used to allow other blocks to visually connect to the botany pot.
     */
    private static ItemStackHandler DUMMY_INV = new ItemStackHandler(0);

Reference:

    @Override
    public <T> LazyOptional<T> getCapability (Capability<T> cap, Direction side) {
        
        if (!this.removed && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && side == Direction.DOWN) {
            
            return LazyOptional.of( () -> DUMMY_INV).cast();
        }
        
        return super.getCapability(cap, side);
    }

I don't see the inventory switching to a real thing in the code, and testing with RefinedPipes's Extractor Attachment never produced any plant goods. This all seems intentional because according to the mod's CurseForge description:

Hopper Botany Pot upgrade allows the pot to harvest itself and put items in a chest or other block with an inventory.

From the description, the code, and a quick test, it seems the Pot is meant to push down, rather than be a target for pulling.
That's not to say the crash is okay, just observations on the Pot side...

On the Smart Chest side... According to the log, the Chest is pulling from the Pot's first slot:

java.lang.RuntimeException: Slot 0 not in valid range - [0,0)
    at net.minecraftforge.items.ItemStackHandler.validateSlotIndex(ItemStackHandler.java:221) ~[?:?] {re:classloading}
    at net.minecraftforge.items.ItemStackHandler.getStackInSlot(ItemStackHandler.java:73) ~[?:?] {re:classloading}
    at me.desht.pneumaticcraft.common.tileentity.TileEntitySmartChest.findNextItem(TileEntitySmartChest.java:206) ~[?:1.16.5-2.13.3-211] {re:classloading}

But the Pot's (fake) inventory has no slots. The validation check fails, the exception is thrown, and the game crashes. On restart, the Chest tries again.

I don't know the ideal solution. It may be enough to have the Chest bail early on a neighbor with a zero-slot inventory.

commented

Exposing via capabilities a 0-sized inventory definitely feels wrong to me, but tbf the smart chest should be more robust about edge cases like this.

This is easy enough to work around in the smart chest code by checking for a 0-sized inventory before trying to search it, so I'll do that.

commented

If you are in a position to try build 217 from https://jenkins.k-4u.nl/job/PneumaticCraft-Repressurized-1.16/ that would be helpful. Should resolve the problem, I think.

commented

Actually no need to test the dev build, I tested myself with E6 - fixed in the 2.13.5 release. You should be able to drop that straight in to E6 with no problems.

commented

Wow, quick fix, thanks!