Ellpeck / NaturesAura

A Minecraft mod about using Aura for unique mechanics
https://modrinth.com/mod/natures-aura
MIT License
47 stars 36 forks source link

BlockSpring's BlockColor errors when world argument is null #320

Closed SuperMartijn642 closed 1 year ago

SuperMartijn642 commented 1 year ago

The BlockColor#getColor method takes 4 arguments, 2 of these are marked @Nullable which includes the world (BlockAndTintGetter) argument. This can indeed be null, for example when called from inside the BlockRenderDispatcher#renderSingleBlock method which doesn't take a world argument.

The implementation of BlockColor#getColor in BlockSpring#getBlockColor calls BiomeColors#getAverageWaterColor with the world argument. Whenever the world argument is null for BiomeColors#getAverageWaterColor, this leads to a null pointer exception. https://github.com/Ellpeck/NaturesAura/blob/5f9897ca1c51cc94bb5a0ac8480b69ae87476a3d/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java#L33-L37

This seems like a simple oversight as BlockGoldenLeaves#getBlockColor does have a null check. https://github.com/Ellpeck/NaturesAura/blob/5f9897ca1c51cc94bb5a0ac8480b69ae87476a3d/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java#L74-L82

In my mod Entangled I happen to use BlockRenderDispatcher#renderSingleBlock to render other blocks in the world. When the rendered block is the BlockSpring from Nature's Aura, this leads to a crash. Original issue here: https://github.com/SuperMartijn642/Entangled/issues/64