Solved Block Breaking Effect

Discussion in 'Plugin Development' started by crolemol, May 10, 2015.

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

    crolemol

    hey,

    so when you're breaking a block there is a kind of effect so you can see how long until it breakes. How can I achieve this effect on a block. Not client-sided as other players can see this so maybe some packet magic?

    2015-05-10_20.26.33.png

    I already saw a plugin using this to cache all damage done and when the effect is complete the block breaks.
     
    Last edited: May 10, 2015
  2. Offline

    mine-care

    @crolemol take a look into a resource called Particle Lib in resource section, it has block crack effect
     
  3. Offline

    crolemol

    @mine-care
    EDIT: nvm i thought you meant protocollib :p but i don't mean the particles but the way the block changes when you're breaking it. the lines
     
  4. Offline

    Signatured

     
  5. Offline

    crolemol

    @SignaturedAren't that just the particles we can see in the picture?
     
  6. Offline

    Signatured

    No, that's the block break effect. I believe he's referring to the cracking black lines like you requested.
     
    mine-care likes this.
  7. Offline

    crolemol

    @Signatured
    oh thx, so how about putting it on a block?

    EDIT: wow seems pretty easy :p thx a lot both, i will post if it didn't work
    EDIT 2: so i didn't use the effect lib but the name pushed me in the right direction and i found an nms packet which does exactly what i want.

    Here is the code to show the lines:
    1.8.x
    Code:
        public void sendBreakPacket(World world, Location location, int data) {
            BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
            PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(0, bp, data);
            for (Player player : world.getPlayers()){
                    ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
            }
        }
    1.7.9 - 1.7.10 (could work with lower versions but not tested)
    Code:
      public static void sendBreakPacket(org.bukkit.World world, Location location, int data{
        PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(0, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data);
        for (Player player : world.getPlayers()){
              ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
        }
      }
    world = the world the block is in
    location = the location of the block
    data = a integer from 1 to 9 which declares how big the lines are

    imports from nms ;) enjoy
     
    Last edited: May 12, 2015
  8. Offline

    mine-care

    @crolemol thanks for piblishing your answer back for the world, and yes indeed in 1.8 it is different but in Plugin Developement 1.8 is not supported :/
     
  9. Offline

    crolemol

    @mine-care
    that's why i referenced how to do it in 1.7 ;)
     
    mine-care likes this.
Thread Status:
Not open for further replies.

Share This Page