Use custom particles with idols fails with null pointer exception
athrane opened this issue ยท 3 comments
Stack trace:
[01Nov2020 22:18:50.165] [Server thread/ERROR] [bassebombecraft.BassebombeCraft/]: java.lang.NullPointerException
at bassebombecraft.network.packet.AddParticleRendering.encode(AddParticleRendering.java:121)
at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryEncode$4(IndexedMessageCodec.java:130)
at java.util.Optional.ifPresent(Optional.java:159)
at net.minecraftforge.fml.network.simple.IndexedMessageCodec.tryEncode(IndexedMessageCodec.java:128)
at net.minecraftforge.fml.network.simple.IndexedMessageCodec.build(IndexedMessageCodec.java:143)
at net.minecraftforge.fml.network.simple.SimpleChannel.encodeMessage(SimpleChannel.java:84)
at net.minecraftforge.fml.network.simple.SimpleChannel.toBuffer(SimpleChannel.java:92)
at net.minecraftforge.fml.network.simple.SimpleChannel.toVanillaPacket(SimpleChannel.java:123)
at net.minecraftforge.fml.network.simple.SimpleChannel.send(SimpleChannel.java:118)
at bassebombecraft.network.NetworkChannelHelper.sendAddParticleRenderingPacket(NetworkChannelHelper.java:105)
at bassebombecraft.item.inventory.GenericInventoryItem.renderEffect(GenericInventoryItem.java:204)
at bassebombecraft.item.inventory.GenericInventoryItem.applyEffect(GenericInventoryItem.java:185)
at bassebombecraft.item.inventory.GenericInventoryItem.inventoryTick(GenericInventoryItem.java:144)
at net.minecraft.item.ItemStack.inventoryTick(ItemStack.java:478)
Error doesn't occur in projectile items.
Seems to be caused by class loading of inventory items where particle rendering objects are initialized from particleConfig objects. At the time of initialization the particles hasn't been registered yet.
Solution is to add delayed resolution of the actual particle type in the class DefaultParticleRenderingInfo
.
Resolution of the particle type is moved from class ConfigUtils to DefaultParticleRenderingInfo.
The result is that particles are resolved when used (i.e. when sent to the client) and not at configuration time where items are configured before the particles are registered in the global registry.
Resolved with commit: 573d35c