Cuberite Forum
Playing with cSignEntities - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Playing with cSignEntities (/thread-1428.html)



Playing with cSignEntities - Narroo - 04-04-2014

Hello there!

Currently, I'm attempting to move a sign in MCServer. I can move the sign block well enough, but the text is stored in a cSignEntity. Looking at the class,

http://mc-server.xoft.cz/doxy/html/de/d3d/a00409.html

I'm not sure how MCServer's housekeeping deals with the creation and removal of cSignEntities. Nor am I sure how to access one using a cBlockSignHandler

For reference, I'm trying to do with in cBlockSignHandler's MetaRotate and MetaMirror functions. I'm pretty sure I can't do what I want, but I'd like to know more about how cSignEntity (and similar objects) work.


RE: Playing with cSignEntities - xoft - 04-04-2014

All the block entities are managed by the cChunk class, and access to them is more or less forbidden, due to multithreading issues. You can only manipulate them from the outside by using cWorld's DoWithBlockEntityAt and the specialized similar functions.


RE: Playing with cSignEntities - Narroo - 04-04-2014

(04-04-2014, 01:31 AM)xoft Wrote: All the block entities are managed by the cChunk class, and access to them is more or less forbidden, due to multithreading issues. You can only manipulate them from the outside by using cWorld's DoWithBlockEntityAt and the specialized similar functions.

Hm, so then I suppose I can't play with the text on a sign from cBlockSignHandler.

In fact, I suppose I couldn't do much with MobHeads either.


RE: Playing with cSignEntities - xoft - 04-05-2014

Why not? All you need is a cWorld pointer, then you can manipulate any sign within the loaded chunks, using the cWorld::DoWithBlockEntityAt() function (if you need, you can write a specific DoWithSignEntityAt() function; although it'd be nice to somehow templatize this piece of code to avoid copy-pasting it to new functions).


RE: Playing with cSignEntities - Narroo - 04-05-2014

(04-05-2014, 12:41 AM)xoft Wrote: Why not? All you need is a cWorld pointer, then you can manipulate any sign within the loaded chunks, using the cWorld::DoWithBlockEntityAt() function (if you need, you can write a specific DoWithSignEntityAt() function; although it'd be nice to somehow templatize this piece of code to avoid copy-pasting it to new functions).

Well, I'm trying to fix up the MetaRotate and MetaMirror Functions for cBlockSignHandler and I don't think I can get any cWorld pointers into that function without rewriting the declarations and calls of all the MetaRotate and MetaMirror Functions. These functions are virtual member functions of cBlockHandler and only take a particular metadata as a parameter.


RE: Playing with cSignEntities - xoft - 04-06-2014

I don't see what sign rotation has in common with the sign text. The text doesn't take part in the rotation and rotating the sign doesn't change the text.

If you're referring to cBlockArea's inability to remember sign areas, that is a completely different issue. cBlockArea needs to get aware of block entities altogether, somehow.


RE: Playing with cSignEntities - Narroo - 04-07-2014

(04-06-2014, 06:07 AM)xoft Wrote: I don't see what sign rotation has in common with the sign text. The text doesn't take part in the rotation and rotating the sign doesn't change the text.

If you're referring to cBlockArea's inability to remember sign areas, that is a completely different issue. cBlockArea needs to get aware of block entities altogether, somehow.

So I need to change cBlockArea then? Is that a reasonable project?


RE: Playing with cSignEntities - xoft - 04-07-2014

It is rather deep, it will most probably require changing quite a bit of BlockEntities' internals (since they assume they are always owned by a cWorld, which won't be the case here; and you need them to be able to duplicate themselves).