Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This should be run on a clock and will update the armour stands position
- * @param p
- * @throws Exception
- */
- public void executeCycle(Player p) throws Exception
- {
- EntityPlayer ep = ((CraftPlayer) p).getHandle();
- PacketPlayOutEntityTeleport teleportStand = new PacketPlayOutEntityTeleport(instance.getStand());
- // 0x08 = has no base plate
- // 0x10 = is a marker type
- byte armourStandMeta = 0x08 | 0x10;
- byte invisibleMeta = 0x20;
- // Creates an armour stand that is used for holding the NPC name
- nmsArmourStand.getDataWatcher().set(new DataWatcherObject<>(15,DataWatcherRegistry.a),armourStandMeta);
- nmsArmourStand.getDataWatcher().set(new DataWatcherObject<>(0,DataWatcherRegistry.a),invisibleMeta);
- ep.b.sendPacket(teleportStand);
- }
- /**
- * Set the text on the armour stand
- * @param text
- */
- public void setText(String text)
- {
- Optional<IChatBaseComponent> name = Optional.of(new ChatMessage(text));
- nmsArmourStand.getDataWatcher().set(new DataWatcherObject<>(2,DataWatcherRegistry.f),name);
- }
- /**
- * Create this armour stand (Send a packet to a player to tell their client it exists)
- * @param p
- */
- public void create(Player p)
- {
- Location loc = p.getLocation();
- nmsArmourStand = new EntityArmorStand(server,loc.getX(),loc.getY(),loc.getZ());
- EntityPlayer ep = ((CraftPlayer) p).getHandle();
- PacketPlayOutSpawnEntityLiving spawnStand = new PacketPlayOutSpawnEntityLiving(nmsArmourStand);
- PacketPlayOutEntityMetadata standMeta = new PacketPlayOutEntityMetadata(nmsArmourStand.getId(),nmsArmourStand.getDataWatcher(),true);
- ep.b.sendPacket(spawnStand);
- ep.b.sendPacket(standMeta);
- }
- /**
- * Destroy this armour stand (Send a packet to a player to tell their client it is gone)
- * @param p
- */
- public void destroy(Player p)
- {
- EntityPlayer ep = ((CraftPlayer) p).getHandle();
- PacketPlayOutEntityDestroy destroyStand = new PacketPlayOutEntityDestroy(nmsArmourStand.getId());
- ep.b.sendPacket(destroyStand);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement