Cardinal-Components-API
Cardinal-Components-API copied to clipboard
Not wanting to attach to non WorldChunk chunks
I only wish to add a component to a chunk if it is a WorldChunk, however the register method requires me to always return a component to be attached, even if it is a ReadOnly chunk. The issue arises when I need to grab information from a chunk on registration, but the ReadOnlyChunk's wrapped chunk is not init-ed yet.
- Register a chunk component and in the registering process try to cache the ChunkPos of the chunk.
- The game should crash with "Cannot invoke getPos in ReadOnlyChunk because this.wrapped is null!"
A workaround is to have a dummy implementation for your chunk component that you attach to anything that is not a WorldChunk. But this seems to be a fairly common problem, so a proper solution seems in order.