Cardinal Components API

Cardinal Components API

21M Downloads

Not wanting to attach to non WorldChunk chunks

amusingimpala75 opened this issue ยท 1 comments

commented

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.

  1. Register a chunk component and in the registering process try to cache the ChunkPos of the chunk.
  2. The game should crash with "Cannot invoke getPos in ReadOnlyChunk because this.wrapped is null!"
commented

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.