Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void spawnPlayerNMS(Player player, UUID playerUUID, Location spawnLoc){
- System.out.println("NMS!");
- PacketPlayOutNamedEntitySpawn entity = new PacketPlayOutNamedEntitySpawn();
- try{
- Field a = entity.getClass().getDeclaredField("a");
- a.setAccessible(true);
- a.set(entity, entityId);
- Field b = entity.getClass().getDeclaredField("b");
- b.setAccessible(true);
- b.set(entity, playerUUID);
- Field c = entity.getClass().getDeclaredField("c");
- Field d = entity.getClass().getDeclaredField("d");
- Field e = entity.getClass().getDeclaredField("e");
- Field f = entity.getClass().getDeclaredField("f");
- Field g = entity.getClass().getDeclaredField("g");
- c.setAccessible(true);
- d.setAccessible(true);
- e.setAccessible(true);
- f.setAccessible(true);
- g.setAccessible(true);
- c.set(entity, spawnLoc.getBlockX());
- d.set(entity, spawnLoc.getBlockY());
- e.set(entity, spawnLoc.getBlockZ());
- f.set(entity, ((byte) ((int) (spawnLoc.getPitch() * 256.0F / 360.0F))));
- g.set(entity, ((byte) ((int) (spawnLoc.getYaw() * 256.0F / 360.0F))));
- Field h = entity.getClass().getDeclaredField("h");
- h.setAccessible(true);
- h.set(entity, 0);
- Field i = entity.getClass().getDeclaredField("i");
- i.setAccessible(true);
- i.set(entity, getWatcher(20));
- } catch (Exception e){
- e.printStackTrace();
- }
- CraftPlayer craftPlayer = (CraftPlayer) player;
- craftPlayer.getHandle().playerConnection.sendPacket(entity);
- }
- public static void destory(Player player){
- PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy();
- try{
- Field a = destroy.getClass().getDeclaredField("a");
- a.set(destroy, new int[]{entityId});
- } catch (Exception e){
- e.printStackTrace();
- }
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(destroy);
- }
- private static DataWatcher getWatcher(float health){
- DataWatcher dw = new DataWatcher(null);
- dw.a(6,health);
- return dw;
- }
Advertisement
Add Comment
Please, Sign In to add comment