Solved Chest open animation

Discussion in 'Plugin Development' started by thorvaldemar, Feb 5, 2017.

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

    thorvaldemar

    Hello out there.

    I'm trying to get a chest to play the opening animation, like when you open a crate on the mineplex server.
    I've read all the answers i could find, but nothing worked. I think it has changed or something in the newer updates.

    I hope some of you have the answer.
     
  2. Offline

    MrGriefer_

  3. Offline

    Disgastings

    @EventHandler
    public void onChestOpen(InventoryOpenEvent e) {
    (e.getInventory().getHolder() instanceof Chest);
    //Do whatever you want here
    }
    }
     
  4. Offline

    thorvaldemar

    @Disgastings No... I want to do something like this:
    [​IMG]
    The chest is opening...
     
  5. Offline

    mehboss

    @thorvaldemar
    You can get the location one above from the chest you opened and put a floating item there with some code.
     
  6. Offline

    Esophose

  7. Offline

    mehboss

    That plays a sound, that doesn't do an item animation..
    Get the opened chest and spawn this one up from the chest.
    Code:
    Entity e = world.dropItem(locofchestopened, new ItemStack(Material.YOURMATERIAL);
    Got it from here:
    https://bukkit.org/threads/floating-entities-frozen-entities-floating-items.313439/

    ALSO, the very last post on this thread is BEYOND useful, I will probably end up doing something like that in the future.
     
  8. Offline

    thorvaldemar

    @mehboss It's not the item, it's the chest... I want to get the chest to open without opening the chest GUI.
     
  9. Offline

    mehboss

    @thorvaldemar
    Oh, then @Esophose's way is correct.
     
  10. Offline

    thorvaldemar

    @Esophose There's just one problem with that... It doesn't do anything.
     
  11. Offline

    Zombie_Striker

    @thorvaldemar
    Post your code. Have you debugged? Is it the fault of your plugin, or is it that the method simply does not work?
     
  12. Offline

    thorvaldemar

    @Zombie_Striker
    No errors, no nothing, this code doesn't do anything...
    Code:
    for (Player player : Bukkit.getOnlinePlayers()) {
           player.playNote(block.getLocation(), (byte) 1, (byte) 1);
    }
     
  13. Offline

    Zombie_Striker

    @thorvaldemar
    PlayNote with bytes have been deprecated. Use the InstramentEnum and NoteEnum instead.
     
  14. Offline

    thorvaldemar

  15. Offline

    Zombie_Striker

    @thorvaldemar
    I don't know the byte values for those things. You must have had something in mind when you chose 1 and 1. Just choose the enum values that you want.
     
  16. Offline

    thorvaldemar

    I found another solution, PACKETS. Here is the code that i ended using:
    Code:
    PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(new BlockPosition(chest.getX(), chest.getY(), chest.getZ()), CraftMagicNumbers.getBlock(chest), 1, 1);
            ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
    Thx for all you help. <3
     
Thread Status:
Not open for further replies.

Share This Page