Skip to content

Unsafe model access of BlockEngineBase_BC8#getEngineParticles causing crash #22

@StockiesLad

Description

@StockiesLad

Crash Report
https://gist.github.com/StockiesLad/86d188f9a7309afcc57d085a99c04b29

Please complete the following information:

  • Forge Version: 47.4.0 (1.20.1)
  • BuildCraft Version (Add Hash if from github): 7.99.24.9-1.20.1-2025-04-26-all

To Reproduce
Steps to reproduce the behavior:
I am actually not sure what exactly triggers it. Breaking and placing the block doesn't trigger it directly, for some reason...

How to fix

 @OnlyIn(Dist.CLIENT)
    private TextureAtlasSprite getEngineParticle(IEngineType engineType) {
        return (TextureAtlasSprite)((LazyLoadedValue)engineParticles.computeIfAbsent(engineType, (e) -> {
            return new LazyLoadedValue(() -> {
                MutableQuad[] var1 = ((ModelHolderVariable)engineModels.get(e)).getCutoutQuads();
                int var2 = var1.length;

                for(int var3 = 0; var3 < var2; ++var3) {
                    MutableQuad quad = var1[var3];
                    if (quad.getFace() == Direction.DOWN) {
                        return quad.getSprite();
                    }
                }

                return (TextureAtlasSprite)SpriteUtil.missingSprite().get();
            });
        })).get();
    }

Instead of directly assigning to the MutableQuad[], perform a null check when performing engineModels.get(), where if null, print a warning, if not null, proceed with the iteration of quads. This will stop the crash, but might result in missingno textures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions