Cardinal-Components-API icon indicating copy to clipboard operation
Cardinal-Components-API copied to clipboard

Not wanting to attach to non WorldChunk chunks

Open amusingimpala75 opened this issue 4 years ago • 1 comments

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!"

amusingimpala75 avatar Mar 07 '21 14:03 amusingimpala75

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.

Pyrofab avatar Mar 18 '21 16:03 Pyrofab