SHARE
TWEET

Untitled

a guest May 25th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  private int entityID;
  2.     private Location location;
  3.     private GameProfile gameprofile;
  4.  
  5.  
  6.     public NPC(String name, Location location) {
  7.         entityID = (int) Math.ceil(Math.random() * 1000) + 2000;
  8.         gameprofile = new GameProfile(UUID.randomUUID(), name);
  9.         changeSkin();
  10.         this.location = location.clone();
  11.     }
  12.  
  13.     public void setHeadRotation() {
  14.        
  15.     }
  16.  
  17.     public void changeSkin() {
  18.         String value = "eyJ0aW1lc3RhbXAiOjE1NTg3MzgwMDE1MTAsInByb2ZpbGVJZCI6IjJmM2E3YWFlYjYxNDQzOGY5YTI3OTVlODhhZGIyZjA3IiwicHJvZmlsZU5hbWUiOiJCaXRydXgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzJlY2M2NGRmYTczZTBjNGU2OGFmZTY2NDg3M2RmMGUyNzAwYjRiNGUwMTczYjVjNWIwMjYwZmZmOTI1NzJlZmIifX19";
  19.         String signature = "mH8XZI+TlxVn3HDtGm6LZZm8dB9UaSfV/LECPyE0aETr7I76SQynYLO5itwb5WkV6I+yOq+iDKd+Rnsg+YQrdTR1Z1iWD3nnkYWRJ/qqJthYGTLcywDaEkG7tQKQ8CD5qa4XfYjXwUfWsKOSK9OSNntoNMrA+CcouHGeG5t57yHN0NuNy2ZmnA55tZi3WkiHLKKErCKGtnXZtBBjy8/AY51ZuP3LaarTOPFIGcwernoX7gMuabdG5EEEFXg/UrYzX22U7yBGczzLKwrlI8LfKgi+amPYvSu9h37TXs286ZWz6v5eQTPyqULKKoIJQ2MbK/ukWbyYDDDvaM+nSlCAbTpAziWmPFSOQfgh6bakTZjk5U0R4pWkLOU5fgFhBRhCtlDc+GAFKy0a/CV03VKO1Jn/RfjiK78YBTnM8mFqYOawM+Z/vz37HiJg0zRVVGaqZn97SzGSjNrS+DR/Z0ZDTDBbUqoyQem69nvgcviwVBplxYCpEOQCVghJc22K7LIxWwQ6xu4keHkPu60MJrWht242VA4UohrEZI+pZISitsCXGF2J9sG3H/SzGOoYhVpHtfWa9Q3yroBpbArGzs36l3qhQCw632cDs3sIEbwUtX0rCO3zZfmtsb2GeYV8g3q5DnUpV4qMU/N+30ecdjpGYDwRTOQhjB1UsoQEe/qjemc=";
  20.         gameprofile.getProperties().put("textures", new Property("textures", value, signature));
  21.     }
  22.  
  23.     public void spawn() {
  24.         PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
  25.  
  26.         setValue(packet, "a", entityID);
  27.         setValue(packet, "b", gameprofile.getId());
  28.         setValue(packet, "c", getFixLocation(location.getX()));
  29.         setValue(packet, "d", getFixLocation(location.getY()));
  30.         setValue(packet, "e", getFixLocation(location.getZ()));
  31.         setValue(packet, "f", getFixRotation(location.getYaw()));
  32.         setValue(packet, "g", getFixRotation(location.getPitch()));
  33.         setValue(packet, "h", 0);
  34.  
  35.         DataWatcher w = new DataWatcher(null);
  36.         w.a(6, (float) 20);
  37.         w.a(10, (byte) 127);
  38.         setValue(packet, "i", w);
  39.         addToTablist();
  40.         sendPacket(packet);
  41.         headRotation(location.getYaw(), location.getPitch());
  42.     }
  43.  
  44.     public void teleport(Location location) {
  45.         PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport();
  46.         setValue(packet, "a", entityID);
  47.         setValue(packet, "b", getFixLocation(location.getX()));
  48.         setValue(packet, "c", getFixLocation(location.getY()));
  49.         setValue(packet, "d", getFixLocation(location.getZ()));
  50.         setValue(packet, "e", getFixRotation(location.getYaw()));
  51.         setValue(packet, "f", getFixRotation(location.getPitch()));
  52.  
  53.         sendPacket(packet);
  54.         headRotation(location.getYaw(), location.getPitch());
  55.         this.location = location.clone();
  56.     }
  57.  
  58.  
  59.     public void headRotation(float yaw, float pitch) {
  60.         PacketPlayOutEntityLook packet = new PacketPlayOutEntityLook(entityID, getFixRotation(yaw), getFixRotation(pitch), true);
  61.         PacketPlayOutEntityHeadRotation packetHead = new PacketPlayOutEntityHeadRotation();
  62.         setValue(packetHead, "a", entityID);
  63.         setValue(packetHead, "b", getFixRotation(yaw));
  64.  
  65.  
  66.         sendPacket(packet);
  67.         sendPacket(packetHead);
  68.     }
  69.  
  70.     public void destroy() {
  71.         PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]{entityID});
  72.         rmvFromTablist();
  73.         sendPacket(packet);
  74.     }
  75.  
  76.     public void addToTablist() {
  77.         PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  78.         PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
  79.         @SuppressWarnings("unchecked")
  80.         List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
  81.         players.add(data);
  82.  
  83.         setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
  84.         setValue(packet, "b", players);
  85.  
  86.         sendPacket(packet);
  87.     }
  88.  
  89.     public void rmvFromTablist() {
  90.         PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  91.         PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
  92.         @SuppressWarnings("unchecked")
  93.         List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
  94.         players.add(data);
  95.  
  96.         setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
  97.         setValue(packet, "b", players);
  98.  
  99.         sendPacket(packet);
  100.     }
  101.  
  102.     public int getFixLocation(double pos) {
  103.         return (int) MathHelper.floor(pos * 32.0D);
  104.     }
  105.  
  106.     public byte getFixRotation(float yawpitch) {
  107.         return (byte) ((int) (yawpitch * 256.0F / 360.0F));
  108.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top