How can I fill a chest of this type?

Discussion in 'Spigot Plugin Development' started by Vrsd12, May 3, 2017.

  1. How can I fill a chest of this type?
    Code (Text):
    FallingBlock block = map.spawnFallingBlock(objspawn, Material.CHEST, (byte) 0);
    And this serves?
    Code (Text):
        public void fallingChest(EntityChangeBlockEvent event){
             if (event.getEntityType() == EntityType.FALLING_BLOCK) {
            if (event.getEntity() instanceof FallingBlock){
                FallingBlock fb = (FallingBlock) event.getEntity();
                if (fb.getMaterial() == Material.CHEST){
                    Chest chest = (Chest) event.getBlock().getState();
                    Inventory inv = chest.getInventory();
                    inv.addItem(new ItemStack(Material.WOOD,1));
  2. First off, it's possible. -> falling_block -> TileEntityData
    The entity can hold tile entity data.

    Secondly, the Bukkit API does not support it.
    org.bukkit.entity.FallingBlock -> Nothing about BlockStates or TileEntities

    Thirdly, so you need to hook into NMS.
    In case of 1.10.2: net.minecraft.server.v1_10_R1.EntityFallingBlock.tileEntityData is public. So shouldn't be too hard to accomplish.
  3. Idea: You can save the chest's location, and when the player tries to open the chest for the first time, fill it with the items you want;)
  4. If you spawn a FallingBlock chest you don't know where it is going to land. So you don't know the location.
    You might listen to some event to recognize, when the FallingBlock hits the ground, then place the chest and fill it.
  5. NathanWolf


    Er, you guys all seemed to miss that OP is already catching when the block lands, that part is handled.

    Have you tried calling chest.update() at the end? That may be all you're missing.
  6. chest.update
    it does not work