Skip to content

Instantly share code, notes, and snippets.

View jordoncodes's full-sized avatar
Accidentally destroying code

Jordon jordoncodes

Accidentally destroying code
  • Australia
  • 16:56 (UTC +10:00)
View GitHub Profile
public void sendBlockDamage(Player player, Location location, float progress) {
int locationId = location.getBlockX() + location.getBlockY() + location.getBlockZ(); // not perfect, could be better (some blocks have duplicate ids)
PacketContainer packet = manager.createPacket(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
// set entity ID to the location so the block break animation doesn't break (this is why we need packets).
packet.getIntegers().write(0, locationId);
packet.getBlockPositionModifier().write(0, new BlockPosition(location.toVector())); // set the block location
packet.getIntegers().write(1, getBlockStage(location)); // set the damage to blockStage
try {
manager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
@jordoncodes
jordoncodes / custom-mining-speed.md
Last active May 5, 2025 13:56
(Minecraft) Tutorial: Custom Block Breaking Speed (custom mining speed) using Spigot API & ProtocolLib.

Custom Mining Speed

Hello, this is a little bit advanced tutorial (using packets) about how to do custom mining speed. This will show you the basics of how to do it.

You may also notice that this has the effect of being able to stop midway thru mining then resume.

Dependencies:

  • ProtocolLib
  • Spigot API (this was tested on 1.19.2)