public static DataWatcher getWatcher(String text, int health) { DataWatcher watcher = new DataWatcher(null); watcher.a(0, (Byte) (byte) 0x20); // Flags, 0x20 = invisible watcher.a(6, (Float) (float) health); watcher.a(10, (String) text); // Entity name watcher.a(11, (Byte) (byte) 1); // Show name, 1 = show, 0 = don't show // watcher.a(16, (Integer) (int) health); //Wither health, 300 = full health return watcher; }
public static PacketPlayOutEntityMetadata getMetadataPacket(DataWatcher watcher) { PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(); Field a = ReflectionUtil.getDeclaredField(metaPacket.getClass(), "a"); a.setAccessible(true); try { a.set(metaPacket, (int) ENTITY_ID); } catch (IllegalArgumentException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } try { Field b = PacketPlayOutEntityMetadata.class.getDeclaredField("b"); b.setAccessible(true); b.set(metaPacket, watcher.c()); } catch (Exception e) { e.printStackTrace(); } return metaPacket; }