Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.benfah.vp.main;
- import java.lang.reflect.Field;
- import java.util.UUID;
- import net.minecraft.server.v1_8_R2.DataWatcher;
- import net.minecraft.server.v1_8_R2.PacketPlayOutNamedEntitySpawn;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
- import org.bukkit.entity.Player;
- public class VirtualPlClass {
- private UUID id;
- private Player pl;
- public VirtualPlClass(UUID uuid, Player p ) {
- id = uuid;
- pl = p;
- pl.getLocation().setYaw(20);
- }
- public void spawn()
- {
- try {
- PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
- set(packet, "b", id);
- set(packet, "c", (int)(pl.getLocation().getX()*32D));
- set(packet, "d", (int)(pl.getLocation().getY()*32D));
- set(packet, "e", (int)(pl.getLocation().getZ()*32D));
- set(packet, "f", (byte)(int)((pl.getEyeLocation().getYaw() * 256F) / 360F));
- System.out.println((byte)(int)((pl.getEyeLocation().getYaw() * 256F) / 360F));
- set(packet, "g", (byte)(int)((pl.getEyeLocation().getPitch() * 256F) / 360F));
- set(packet, "h", 276);
- DataWatcher w = new DataWatcher(null);
- w.a(6, (float)20F);
- w.a(10, (byte) 127);
- set(packet, "i", w);
- for(Player p : Bukkit.getOnlinePlayers())
- {
- ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void set(Object instance, String name, Object value) throws Exception
- {
- Field field = instance.getClass().getDeclaredField(name);
- field.setAccessible(true);
- field.set(instance, value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement