Solved Make a chest like its open

Discussion in 'Plugin Development' started by theCodeBro, Jun 15, 2013.

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

    theCodeBro

    I'm trying to recreate the chest system from zelda ocarina of time. Basically, if you open a chest you will just get one item without seeing like an inventory, and the chest will always look like its open,= (Because you opened it). But i have trouble making he chest look like that. Does anybody know how to do it?
     
  2. Offline

    DarkBladee12

    theCodeBro That's a code for opening/closing chests which I used in UltimateRockets:

    Code:
        public void changeChestState(Location loc, boolean open) {
            if (open) {
                for (Player p : Bukkit.getOnlinePlayers()) {
                    p.playNote(loc, (byte) 1, (byte) 1);
                }
            } else {
                 for (Player p : Bukkit.getOnlinePlayers()) {
                     p.playNote(loc, (byte) 1, (byte) 0);
                 }
            }
        }
     
  3. Offline

    theCodeBro

  4. Offline

    metalhedd


    that's interesting.. what's the logic behind it? does the server just re-use the noteblock packet for the chest opening animation and this is just a clever way to trick it?
     
  5. Offline

    Hoolean Retired Staff

    DarkBladee12

    Just optimised your code a bit :p

    Code:
    public void changeChestState(Location loc, boolean open) {
        for (Player p : loc.getWorld().getPlayers()) {
            p.playNote(loc, (byte) 1, (byte) (open ? 1 : 0));
        }
    }
     
  6. Offline

    tehbeard

    Note blocks, chests and pistons use the block action packet, context of packet depends on block at the location
     
  7. Offline

    Wizardo367

    If your question has been answered then please mark the thread as solved. :p
     
  8. Offline

    theCodeBro

    oops sry
     
Thread Status:
Not open for further replies.

Share This Page