Blocks are now officially useless as storage

Discussion in 'Resources' started by bergerkiller, Mar 31, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    bergerkiller

    Issue ticket link

    Blocks are now completely useless for storage. Need to store a Block for more than one tick? Well, don't, because there is a big chance that the Block becomes completely useless.

    Blocks can only be used for temporary usage, like using a Block from an Event. It can not be stored in a Collection and can't even be mapped to something, because the Block will eventually 'glitch out' once the chunk it is in, unloads.

    It was already an issue to store them because worlds could unload, the chunk unloading problem now adds to this.


    Well, Bukkit has no build-in 'offline' block storage system. You will have to include your own Offline block class to deal with it. In my plugins, I use BlockLocation combined with a BlockMap/BlockSet.

    If world is unimportant, I also have IntVector3 for storing the x/y/z coordinates.

    Next time you need to store something: don't use Blocks, ever.
     
    ferrybig and chasechocolate like this.
  2. can you store block metadata (sign lines, chest inventory) with your block objects, bergerkiller ?
    EDIT: nvm, misread the post? let me look again
    EDIT 2: still not sure how you used those classes to save the metadata
     
  3. Offline

    bergerkiller

    ferrybig
    No, these are literally Block Locations, they do not store any block data. If you want to obtain Block metadata or other stuff, you will have to create a temporary Block instance to obtain it, or use World.getBlockEtc. to get it. It is actually possible to add methods for it though, but it would be less efficient as it has to obtain a World instance by name every time you use it.
     
Thread Status:
Not open for further replies.

Share This Page