Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.51 KB | None | 0 0
  1. nplist.add(args[1]);
  2. List<Integer> stringl = nd.getData().getIntegerList("IdList");
  3.  int entityID = (int)Math.ceil(Math.random() * 1000) + 2000;
  4.   stringl.add(entityID);
  5.   nplist.add(args[1]);
  6.  nd.getData().set("NpcList", nplist);
  7.  nd.getData().set("IdList", stringl);
  8.  nd.getData().set(args[1] + ".Location.X" , p.getLocation().getX());
  9.  nd.getData().set(args[1] + ".Location.Y" , p.getLocation().getY());
  10.  nd.getData().set(args[1] + ".Location.Z" , p.getLocation().getZ());
  11.  nd.getData().set(args[1] + ".Location.Yaw" , p.getLocation().getYaw());
  12.  nd.getData().set(args[1] + ".Location.Pitch" , p.getLocation().getPitch());
  13.  nd.getData().set(args[1] + ".Location.World" , p.getWorld().getName());
  14.  nd.getData().set(args[1] + ".Id", entityID);
  15.  
  16.  
  17.  //spawn npc
  18.  McSession session = McSession.search(args[1]);
  19.  McSession.Property pa = session.getProperties("textures");
  20.  String signa = pa.getString("Signature");
  21.  String value =  pa.getString("value");
  22.  GameProfile gf = new GameProfile(UUID.fromString("634b2d92-f33e-4d79-9961-95a24a1f941b"), args[2]);
  23.  gf.getProperties().put("textures", new Property("textures", value , signa));
  24.  MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
  25.  WorldServer nmsWorld = ((CraftWorld) p.getWorld()).getHandle();
  26.  npc = new EntityPlayer(nmsServer, nmsWorld, gf, new PlayerInteractManager(nmsWorld));
  27.  //send packets
  28. npc.setPositionRotation(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), p.getLocation().getYaw(), p.getLocation().getPitch());
  29.  PacketPlayOutNamedEntitySpawn packet  = new PacketPlayOutNamedEntitySpawn(npc);
  30.  
  31. setValue(packet, "a", entityID);
  32. setValue(packet, "c", p.getLocation().getX());
  33. setValue(packet, "d", p.getLocation().getY());
  34. setValue(packet, "e", p.getLocation().getZ());
  35. setValue(packet, "f", getfixhead(p.getLocation().getYaw()));
  36. setValue(packet, "g", getfixhead(p.getLocation().getPitch()));
  37. sender.sendMessage(pf + " Je hebt een npc gespawnt met de naam " + ChatColor.DARK_AQUA +  args[1]);
  38.  
  39. for(Player pd : Bukkit.getOnlinePlayers()) {
  40.      
  41.  PlayerConnection connection = ((CraftPlayer) pd).getHandle().playerConnection;
  42.  connection.sendPacket(packet);
  43.  connection.sendPacket(new PacketPlayOutEntityMetadata(entityID, npc.getDataWatcher(), true));
  44.  connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
  45. connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
  46.  }
  47.  Bukkit.getServer().getConsoleSender().sendMessage("Er heeft iemand een npc gespawnd");
  48.  nd.saveData();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement