Solved Spawn falling chest - not rendering

Discussion in 'Spigot Plugin Development' started by Voidev, Sep 24, 2016.

  1. Hey guys,
    so I'm currently writing a plugin which has to spawn a falling block; a chest.
    Code (Java):
    public class FallingBlockCommandExecutor implements CommandExecutor
    {

        //
        // Just a quick test command to test the falling block chest stuff
        //

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
         
            if (!(sender instanceof Player))
            {
                sender.sendMessage("§cYou're not a player!");
                return true;
            }
         
            Player player = (Player) sender;
         
            @SuppressWarnings("deprecation")
            FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getLocation(), Material.CHEST, (byte) 0);
         
            fallingBlock.setDropItem(false);
            //fallingBlock.setGravity(true);  removed for version compatibility with 1.8<
            fallingBlock.setHurtEntities(false);
            //fallingBlock.setInvulnerable(true);  removed for version compatibility with 1.8<
            fallingBlock.setMetadata("dropevent", new FixedMetadataValue(DropEventPlugin.getInstance(), true));
            fallingBlock.setTicksLived(1);
         
            sender.sendMessage("§aFalling block spawned");
         
            return true;
         
        }

    }
     
    The problem is that the chest doesn't render until it has hit the ground and therefore turned into a block.
    I have tried it on 1.10 and 1.8, and it doesn't work on either version.
    The weird thing is that if I change Material.CHEST to, e.g. Material.STONE, it works perfectly fine.
    Does anybody know a fix for this? Ideally not using NMS, but I could live with NMS as well ;)
    Thanks in advance for any help
     
  2. maybe

    fallingblock chests have always rendered for me, maybe it's a client or OptiFine issue
     
  3. Yeah, I do use Optifine. Let me test it without it.
    EDIT: Nope, still no luck.
    I added the fallingBlock.setTicksLived(1) because it was a suggestion from the internet. Without it, it wouldn't work either.
     
  4. Does it render if you spawn it with a command?
    Code (Text):
    /summon FallingSand ~ ~20 ~ {Block:chest,Time:1}
     
  5. Strangely, it does not.
     
  6. I just tested it and it seems to be a client issue since a specific version, you can't do anything about it
     
  7. Ok, well that's too bad. Thanks though :)

    EDIT: Or could you maybe do something with packets?
     
  8. A hacky way of doing this would to just spawn a chest at y=250 (or whatever is the maximum height) and just movie it down 1 block ever few ticks.
     
  9. That kinda defeats the purpose if he wants to use a FallingBlock.
     
  10. Yeah, and also, that would make stuff way more complicated than it needs to be. I think I'm better of just using like, a diamond block or something, and then replacing it with a chest once it lands.
     
  11. Perhaps you could use a player head with a chest skin?
    Although I'm not sure FallingBlock will work with that.
     
  12. A hacky solution could potentially be an armour stand affected by gravity with its head set as a chest, and the rest of the stand's body is completely invisible.
     
    • Creative Creative x 2
  13. That might actually work. Gonna test that tomorrow.
     
    • Like Like x 1
  14. Chests dont have a falling block texture
     
  15. It had once but I don't know why they removed it