Single block data storage
I'm afraid I don't quite understand your question. What's a world handler? And each block entity already has coordinates...
Thanks given by:
gah, I mean pointer to cWorld. There is method: GetBlockMeta() and I'm looking to something similar to get block entity.
Thanks given by:
Long story short: there can't be such a method, due to multithreading. I'll elaborate in a while (edit this post)
Imagine there was a GetBlockEntity() method (it used to be there Wink
Now, thread A calls the method, and it returns the block entity for given coords.
In the meantime, thread B receives a packet from a player that they have finished mining block at those exact same coords. Thread B calls cWorld::DigBlock() and the block entity is destroyed.
Now thread A has a pointer to a dead block entity, crashing the server when it tries to do anything with that pointer.

The same situation was with players and other entities.

The solution to this madness was to provide generic functions DoWithXYZ() that make your callback code execute while the respective object is locked and cannot be touched by any other thread (Java calls this Synchronized, I believe). If you need to address all objects of the kind in the chunk, there's also a cWorld::ForEachXYZInChunk() method that calls the callback for each object.

However, writing such callbacks is a major pain in the a**, so there are some utility functions that provide often-used functionality, such as GetSignLines() (and I expect more to come sooner or later)
Thanks given by: l0udPL
So, to sum up, to connect note blocks to redstone I would have to create:

- TriggerNote(position) in cWorld that would call
- TriggerNote(position) in cChunkMap that would create a m_CSLayers lock and call
- TriggerNote(position) in cChunk that would find entity and call MakeSound()?

I don't know... it looks complicated. Especially cWorld becomes overloaded by all this entity-related stuff... Or there is more effective method than that.. tunelling?
Thanks given by:
Essentially, that's it.

cWorld is meant to be a hub for all such calls. Since most of its functionality is implemented in other sub-objects, it exists mostly just to relay "commands" to those sub-parts Smile

Rather than TriggerNote(), I'd personally prefer PlayNoteBlockAt(), which better describes what the function does.
Thanks given by:

Users browsing this thread: 1 Guest(s)