Cloning a Block (in 1.14.4)

Discussion in 'Spigot Plugin Development' started by NaomyNaomy, Aug 30, 2019.

  1. Hi,
    my plan is to copy this area of blocks to another area like the /clone command in Minecraft,
    but I want a Block Entity flying from my location to the location where its cloned in the other area.
    My issue is that Sign's and Chest's and so on don't keep there BlockMeta / Data. Does someone know how to do this "copy/clone" block thing?
     
  2. Blocks with Inventories and Chests dont have this Data stored in their Metadata.

    What you could do is, you can get the Corresponding Object, and get the Inventory/Data from this Object by using Block#getState() and then Casting it to the correct Block.
    For example, if you want to get the Chests Inventory use something along this:
    Code (Text):
    Chest c = (Chest) b.getState();
    Inventory inv = c.getInventory();
    But just cast Objects to their correct Class/Object otherwise you´ll get an error.
     
  3. Okay I'll do that