Store Tile Entity

Discussion in 'Plugin Development' started by Nitnelave, Feb 28, 2013.

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

    Nitnelave

    Hello!
    I need to store the exact state of a block without needing to know what it is (for example in case of mods adding new blocks), in order to replace it later on. For that, I think I need to store the TileEntity. But the problem is, I can't do that with the Bukkit API (as far as I know), and I don't want to use CraftBukkit because of the safeguard system.

    Anyone has a solution?
     
  2. Offline

    jorisk322

    Doesn't the block-object include this data?
     
  3. Offline

    Nitnelave

    What do you mean by block-object? If you mean the BlockState, then no, it doesn't (unless it's hidden somewhere, but I highly doubt it). For example, if you do blockstate.update(true), it will not replace custom blocks.
     
  4. Offline

    juampi_92

    I think he means this:
    Block

    The function getData() or the setData()

    or maybe try with the bukkit metadata?
     
  5. Offline

    ZachBora

    Nitnelave You could check how WorldEdit handles copies and such, as it supports custom blocks.
    I tried to understand it one night but I wasn't able to, there are many classes created to achieve it.
     
  6. Offline

    Nitnelave

    juampi_92 It is not the Block class, the get/setdata is a byte, so it definitely does not contains what I'm looking for. And anyway, a block represents the current state of a location in the world, and I want to save it....
    ZachBora I'll have a look. I gave it a cursory glance, but I didn't know it supported custom blocks.
     
  7. Offline

    ZachBora

    I think it does, sk89q made a video of himself copying technocraft or whatever that server with tubes is.
     
  8. Offline

    Cybermaxke

    I already made myself a api to store data into blocks/chunks.
    You can get the source here: https://github.com/Cybermaxke/ChunkDataAPI
    You still need to remove the tags, when breaking, exploding, ...
    and intialize with 'new ChunkDataAPI(plugin);'
     
  9. Offline

    agaricus

    I assume you're referring to this video? http://m.youtube.com/#/watch?v=FkCtjBL-7vs

    It's from some time ago, but says "coming soon" -- maybe a WorldEdit dev can clarify, but as I understand it, the latest dev builds have full support for modded blocks. This includes 4096 block ID support and custom tile entities.

    WorldEdit does hook into NMS for this purpose. However, it does it safely, only using the appropriate NMS handler for the respective CraftBukkit version (check "nmsblocks" in the WE source; also they can be loaded dynamically without updating the rest of the plugin), and will fallback to the Bukkit API if no compatible NMS is available.

    Sounds like it would be useful to expose this functionality from WorldEdit to other plugins. Maybe it already does, or could be added to the API? If so, plugins could add WorldEdit as a dependency and use its block/tile entity handling when possible.

    However, I'm curious what problems exactly people are seeing with BlockState. Does getting the state and restoring it not preserve custom NBT? If so, perhaps this is fixable in the mods themselves.

    Looks cool, does this support 4096 block IDs and custom tile entities?
     
  10. Offline

    Cybermaxke

    agaricus
    Basicly just tags you have to add yourself, so yes :p
     
  11. Offline

    ZachBora

    agaricus One of the issues I had was to successfully copy a whole block and its properties into another block. For example containers, skulls contain special data that can only be accessed by changing the blockstate to the actual object that inherits blockstate. If there was a way to do this without having custom code for some blocks, a way to get all the information on the block and move it somewhere else.

    Cybermaxke Does it support Containers and skulls? I don't see in the source how it would do that.
     
  12. Offline

    Cybermaxke

    ZachBora
    Just to use for custom tags, cause the bukkit didn't save my metadatas, so I made that.
    Ah, didn't read so good what he wanted to do. >.<

    Then it would require nms. :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page