Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int entityID;
- private Location location;
- private GameProfile gameprofile;
- public NPC(String name, Location location) {
- entityID = (int) Math.ceil(Math.random() * 1000) + 2000;
- gameprofile = new GameProfile(UUID.randomUUID(), name);
- changeSkin();
- this.location = location.clone();
- }
- public void setHeadRotation() {
- }
- public void changeSkin() {
- String value = "eyJ0aW1lc3RhbXAiOjE1NTg3MzgwMDE1MTAsInByb2ZpbGVJZCI6IjJmM2E3YWFlYjYxNDQzOGY5YTI3OTVlODhhZGIyZjA3IiwicHJvZmlsZU5hbWUiOiJCaXRydXgiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzJlY2M2NGRmYTczZTBjNGU2OGFmZTY2NDg3M2RmMGUyNzAwYjRiNGUwMTczYjVjNWIwMjYwZmZmOTI1NzJlZmIifX19";
- 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=";
- gameprofile.getProperties().put("textures", new Property("textures", value, signature));
- }
- public void spawn() {
- PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
- setValue(packet, "a", entityID);
- setValue(packet, "b", gameprofile.getId());
- setValue(packet, "c", getFixLocation(location.getX()));
- setValue(packet, "d", getFixLocation(location.getY()));
- setValue(packet, "e", getFixLocation(location.getZ()));
- setValue(packet, "f", getFixRotation(location.getYaw()));
- setValue(packet, "g", getFixRotation(location.getPitch()));
- setValue(packet, "h", 0);
- DataWatcher w = new DataWatcher(null);
- w.a(6, (float) 20);
- w.a(10, (byte) 127);
- setValue(packet, "i", w);
- addToTablist();
- sendPacket(packet);
- headRotation(location.getYaw(), location.getPitch());
- }
- public void teleport(Location location) {
- PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport();
- setValue(packet, "a", entityID);
- setValue(packet, "b", getFixLocation(location.getX()));
- setValue(packet, "c", getFixLocation(location.getY()));
- setValue(packet, "d", getFixLocation(location.getZ()));
- setValue(packet, "e", getFixRotation(location.getYaw()));
- setValue(packet, "f", getFixRotation(location.getPitch()));
- sendPacket(packet);
- headRotation(location.getYaw(), location.getPitch());
- this.location = location.clone();
- }
- public void headRotation(float yaw, float pitch) {
- PacketPlayOutEntityLook packet = new PacketPlayOutEntityLook(entityID, getFixRotation(yaw), getFixRotation(pitch), true);
- PacketPlayOutEntityHeadRotation packetHead = new PacketPlayOutEntityHeadRotation();
- setValue(packetHead, "a", entityID);
- setValue(packetHead, "b", getFixRotation(yaw));
- sendPacket(packet);
- sendPacket(packetHead);
- }
- public void destroy() {
- PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]{entityID});
- rmvFromTablist();
- sendPacket(packet);
- }
- public void addToTablist() {
- PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
- PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
- @SuppressWarnings("unchecked")
- List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
- players.add(data);
- setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
- setValue(packet, "b", players);
- sendPacket(packet);
- }
- public void rmvFromTablist() {
- PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
- PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(gameprofile.getName())[0]);
- @SuppressWarnings("unchecked")
- List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
- players.add(data);
- setValue(packet, "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER);
- setValue(packet, "b", players);
- sendPacket(packet);
- }
- public int getFixLocation(double pos) {
- return (int) MathHelper.floor(pos * 32.0D);
- }
- public byte getFixRotation(float yawpitch) {
- return (byte) ((int) (yawpitch * 256.0F / 360.0F));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement