mrkirby153

Untitled

Apr 28th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. public static void spawnPlayerNMS(Player player, UUID playerUUID, Location spawnLoc){
  2. System.out.println("NMS!");
  3. PacketPlayOutNamedEntitySpawn entity = new PacketPlayOutNamedEntitySpawn();
  4. try{
  5. Field a = entity.getClass().getDeclaredField("a");
  6. a.setAccessible(true);
  7. a.set(entity, entityId);
  8. Field b = entity.getClass().getDeclaredField("b");
  9. b.setAccessible(true);
  10. b.set(entity, playerUUID);
  11. Field c = entity.getClass().getDeclaredField("c");
  12. Field d = entity.getClass().getDeclaredField("d");
  13. Field e = entity.getClass().getDeclaredField("e");
  14. Field f = entity.getClass().getDeclaredField("f");
  15. Field g = entity.getClass().getDeclaredField("g");
  16. c.setAccessible(true);
  17. d.setAccessible(true);
  18. e.setAccessible(true);
  19. f.setAccessible(true);
  20. g.setAccessible(true);
  21. c.set(entity, spawnLoc.getBlockX());
  22. d.set(entity, spawnLoc.getBlockY());
  23. e.set(entity, spawnLoc.getBlockZ());
  24. f.set(entity, ((byte) ((int) (spawnLoc.getPitch() * 256.0F / 360.0F))));
  25. g.set(entity, ((byte) ((int) (spawnLoc.getYaw() * 256.0F / 360.0F))));
  26. Field h = entity.getClass().getDeclaredField("h");
  27. h.setAccessible(true);
  28. h.set(entity, 0);
  29. Field i = entity.getClass().getDeclaredField("i");
  30. i.setAccessible(true);
  31. i.set(entity, getWatcher(20));
  32. } catch (Exception e){
  33. e.printStackTrace();
  34. }
  35. CraftPlayer craftPlayer = (CraftPlayer) player;
  36. craftPlayer.getHandle().playerConnection.sendPacket(entity);
  37. }
  38.  
  39. public static void destory(Player player){
  40. PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy();
  41. try{
  42. Field a = destroy.getClass().getDeclaredField("a");
  43. a.set(destroy, new int[]{entityId});
  44. } catch (Exception e){
  45. e.printStackTrace();
  46. }
  47. ((CraftPlayer) player).getHandle().playerConnection.sendPacket(destroy);
  48. }
  49.  
  50. private static DataWatcher getWatcher(float health){
  51. DataWatcher dw = new DataWatcher(null);
  52. dw.a(6,health);
  53. return dw;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment