How could I store custom block data without using any external storage methods? My anti-lag plugin clears the block cache every 5 minutes, and the block object gets destructed.
I remember doing something like that when I was working on custom TNT. You can try using Level::setBlockExtraDataAt()
However, it seems that getBlockExtraDataAt returns this: ($data << 8) | $blockId. How would I reverse that to get the value I stored? Is it even possible to reverse bitwise operations?
Yeah, except that tile overload lag = 1/2 entity overload lag (totally accurate). You can get the value using Level::getBlockExtraDataAt()
Yeah, but it is ($originalData << 8) | $blockId. So how am I gonna reverse a bitwise or and a bitshift?
Blocks don't have NBT data; you have to use a tile if you want to use NBT. You also need to work around troubles like accidentally sending the tile to the client.
I know. That's why I am trying to figure out a way to store data without actually using tiles (NBT) or other external storage methods.
Yeah, a disadvantage of using tiles is that you may override/be overridden by other tiles, e.g. you can't store data for signs and chests. Therefore I still believe that storing externally is a good idea. PocketMine has a block metadata API, but I doubt if it even gets saved at all.