Block breaking Animation

Discussion in 'Plugin Development' started by MattTheBeast, Aug 10, 2017.

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

    MattTheBeast

    So to keep this short I created my way of breaking certain blocks where the crack in the block wont go away and this way I can manipulate the durability, I make the breaking animation stay using packets like so:

    Code:
        private void sendBlockBreak(int damage) {
            PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(this.entity.getId(),
                    new BlockPosition(loc.getBlock().getX(), loc.getBlock().getY(), loc.getBlock().getZ()), damage);
           
             ((CraftServer)Bukkit.getServer()).getHandle().sendPacketNearby(null, this.loc.getX(), this.loc.getY(), this.loc.getZ(), 120.0D, this.serverWorld.dimension, 
                    packet);
        }
    
    The only problem I have is that the block breaking animation that I didn't send (The original block breaking animation) still stays. This cant obvioustly be cancelled using simple events like the blockdamage and the interact, so I'v been really struggling finding a way to cancel it. If anybody knows a way I can cancel it or if I can make it very long, or make it undestructable Id really appreciate it. Thanks
     
  2. Offline

    Horsey

    You can use a packet listener like TinyProtocol, or just hook into ProtocolLib.
     
  3. Offline

    MattTheBeast

    @Horsey

    Iv tryed to cancel it with ProtocolLib but I'm having trouble, can you give a me example or explanation on how to do you if your familiar with this kind of thing, thanks.

    Maybe cancelling the packet is to hard. Does anybody know how to change the durability of existing minecraft blocks? Id change the durability to a obsurd value like bedrock or something

    I tryed to set the block hardness, but it wont work, can anybody help me out?
    Code:
            try{
                Method method = net.minecraft.server.v1_8_R3.Block.class.getDeclaredMethod("c", float.class);
                method.setAccessible(true);
                Block b = CraftMagicNumbers.getBlock(Material.STONE);
                method.invoke(b, 6000000.0F);
            }catch (Exception e) {
                e.printStackTrace();
            }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited: Aug 11, 2017
Thread Status:
Not open for further replies.

Share This Page