Created
August 5, 2013 04:48
-
-
Save anonymous/6153589 to your computer and use it in GitHub Desktop.
This file contains 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 static void setBossBar(String text, Player player, int percentage) { | |
int maxBar = 300; | |
int currentBarHealth = (int)(((float)percentage / 100) * (float)maxBar); | |
hasHealthBar.put(player.getName(), true); | |
Location mobLocation = player.getLocation(); | |
double viewX = Math.toRadians(player.getLocation().getYaw() - 90); | |
mobLocation.setX(mobLocation.getX() - Math.cos(viewX) * 100); | |
mobLocation.setZ(mobLocation.getZ() - Math.sin(viewX) * 100); | |
mobLocation.setY(mobLocation.getY() - 34); | |
Packet24MobSpawn mobPacket = getMobPacket(text, mobLocation); | |
sendPacket(player, mobPacket); | |
DataWatcher watcher = getWatcher(text, currentBarHealth); | |
Packet40EntityMetadata metaPacket = getMetadataPacket(watcher); | |
sendPacket(player, metaPacket); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment