Show chest animation

Discussion in 'Plugin Development' started by Codisimus, Jan 28, 2014.

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

    Codisimus

    The recent CraftBukkit/Minecraft changes broke my hack which showed a chest opening/closing to a player. I am wondering if anyone knows how the chest animation is sent to the player now. I would think a packet but I am not very good with them. Any suggestions are welcomed. The code that use to work was...

    Code:java
    1. player.playNote(loc, (byte) 1, (byte) 1); //Open animation
    2. player.playNote(loc, (byte) 1, (byte) 0); //Close animation


    As I said, it was a hack that played a "note" for the chest. Now that code plays some sort of bass sound.

    I hope someone knows how to do this because it greatly improves the visuals of my PhatLoots plugin.

    Thanks :)
     
  2. Offline

    Garris0n

  3. Offline

    Codisimus

    Thanks, I could find the code in CraftBukkit. It looks like the magic behind it hasn't changed. I think it is the playNote method that Bukkit provides that now only supports note blocks. I will have to do more testing. At least I know that I can access NMS as a last resort.
     
  4. Offline

    Garris0n

    https://github.com/Bukkit/CraftBukk...kkit/craftbukkit/entity/CraftPlayer.java#L264

    https://github.com/Bukkit/CraftBukk...kkit/craftbukkit/entity/CraftPlayer.java#L247

    That's what's changed.

    For some reason, the world.playnote does a bunch of stuff that ends up here:
    https://github.com/Bukkit/CraftBukk...et/minecraft/server/TileEntityChest.java#L328

    I'm not really even sure what's going on at that point, obfuscation sucks.

    I'm assuming the game has changed its way of notifying the player, maybe it's in a different packet or a part of the inventory packet.
     
  5. I've the same problem...
    I only found out how to open a chest:
    Code:java
    1.  
    2. Block b = yourChest;
    3. int x = b.getX(), y = b.getY(), z = b.getZ();
    4. ((CraftWorld) b.getWorld()).getHandle().playNote(x, y, z, CraftMagicNumbers.getBlock(b), 1, 1);
     
  6. Offline

    Desle

    jofkos Codisimus
    To close it's probably this, right?

    Code:java
    1. Block b = yourChest;
    2. int x = b.getX(), y = b.getY(), z = b.getZ();
    3. ((CraftWorld) b.getWorld()).getHandle().playNote(x, y, z, CraftMagicNumbers.getBlock(b), 1, 1);
     
  7. Offline

    Codisimus

    Desle
    My previous hack used 1 to open and 0 to close so I would think it would be the same. But jofkos is saying that 0 opens the chest so ya, I would think 1 should close it.
     
  8. It's plays the close sound, but the chest is still open...
     
  9. Offline

    Codisimus

    jofkos does the chest inventory still have a viewer? that might keep it open.
     
  10. Open:
    Code:java
    1. ((CraftWorld) b.getWorld()).getHandle().playNote(x, y, z, CraftMagicNumbers.getBlock(b), 1, 1);

    Close:
    Code:java
    1. ((CraftWorld) b.getWorld()).getHandle().playNote(x, y, z, CraftMagicNumbers.getBlock(b), 1, 0);

    I think the last value is the number of viewers
     
Thread Status:
Not open for further replies.

Share This Page