PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

43M Downloads

[1.16.5] NPE when building pressure chamber with building gadgets

P3pp3rF1y opened this issue ยท 4 comments

commented

Minecraft Version

1.16.5

Forge Version

1.16.5-36.1.0

Mod Version

1.16.5-2.11.3-168

Describe your problem, including steps to reproduce it

Tried placing pressure chamber blocks using building gadgets and got the NPE crash. https://pastebin.com/7X3yq362

Looks like neighbourCache isn't initialized because building gadgets is able to place multiple blocks in the same tick and validate didn't run for the tile yet. https://github.com/TeamPneumatic/pnc-repressurized/blob/1.16.4/src/main/java/me/desht/pneumaticcraft/common/tileentity/TileEntityBase.java#L403
Perhaps a simple null check will help here before calling neighbourCache::purge.

commented

Yeah, a null check would probably fix this, although looking again, I wonder why I didn't just create a final neighbour cache object in the TE constructor (I have a feeling I tried, and there was a reason not to, but I can't remember now :) ).

I'll do some testing on this and find the cleanest solution.

commented

Just FYI, I have added that null check in a version I am using as I wanted to fix my world I've been playing and it seems to work well - pressure chamber forms without issues. Though of course I don't know all the intricacies of what that field is used for.

commented

It's just there for performance (PNC:R TE's cache their immediate neighbours, clearing the cache whenever the TE sees a neighbour block update).)

Update: been testing some changes (using a final neighbourCache field) and it's working pretty well. I guess there is the risk of a TE caching a negative result when this happens, but it shouldn't be a problem for the pressure chamber wall blocks (they never need to check their neighbours; they're only tile entities so they can store the blockpos of the controlling valve).

I also tested placing a run of pressure tubes with the building gadets, and that worked almost perfectly. Server-side everything's fine, and air flows down them, but any existing tube that the new run of tubes is placed against doesn't get its clientside blockstate updated, so appears unconnected (forcing a block update by placing something next to it resolves that). That is just a cosmetic problem, and could be difficult to fix; it's likely happening because the building gadget is placing all the blocks server-side (so the client doesn't know to update neighbours, as it would if a player places the block down manually).

commented

Fixed in 2.12.0