Solved Mining Speed

Discussion in 'Plugin Development' started by BaddCamden, Feb 18, 2021.

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

    BaddCamden

    I am trying to make a plugin that relies on custom mining speed for pickaxes, however many people have said it is impossible. Recently though, hypixel released an update adding custom mining speed to their custom pickaxes in Skyblock. This proves that it is possible, however, I still need to know how to do it. Any suggestions?

    (Also, I think this is the right forum to ask this. If it isn't, tell me so I can move it over to a different forum)
     
  2. Offline

    Kars

    Packets.
     
  3. Offline

    BaddCamden

    Elaborate
     
  4. Offline

    Kars

    @BaddCamden they likely use packets to show the block-breaking textures faster. That or they increase the Efficiency enchantment and mask it somehow.
    Either way, if you don't care about the texture you can just break the block faster.
     
  5. Offline

    BaddCamden

    OK, so i did a bit of research based on what you have said, and I have come up with this,
    Code:
    package me.BaddCamden.MainSkyblock;
    
    import java.lang.reflect.Field;
    
    import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    
    import net.minecraft.server.v1_16_R3.BlockPosition;
    import net.minecraft.server.v1_16_R3.PacketPlayOutBlockBreakAnimation;
    
    
    
    public class MiningSpeed implements Listener{
       
        Main mainPlugin;
        public MiningSpeed(Main main) {
            mainPlugin = main;
        }
       
        @EventHandler
        public void OnBlockHit(PlayerInteractEvent event) {
            CraftPlayer p = (CraftPlayer) event.getPlayer();
            if(event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
                PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(event.getPlayer().getEntityId(), new BlockPosition(event.getClickedBlock().getX(), event.getClickedBlock().getY(), event.getClickedBlock().getZ()), 3);
                try {
                    Field field = packet.getClass().getDeclaredField("a");
                    field.setAccessible(true);// allows us to access the field
                 
                    field.setInt(packet, 123);// sets the field to an integer
                    field.setAccessible(!field.isAccessible());//we want to stop accessing this now
                } catch(Exception x) {
                    x.printStackTrace();
                }
                p.getHandle().playerConnection.sendPacket(packet);
            }
        }
    }
    
    
    (this does not work independently for any new programmers)

    All this does is change the block breaking texture to the third breaking stage. I plan on expanding upon this later, and hopefully this can be of some help to others.
     
Thread Status:
Not open for further replies.

Share This Page