Created
December 6, 2022 04:57
-
-
Save jordoncodes/3602e7a6a05715458a84904fee861f75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
e.printStackTrace(); // the packet was unable to send. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment