@Override public Object addMessage(Hologram hologram, String message) { EntityArmorStand lastAs = hologram.getArmorStands().size() == 0 ? null : (EntityArmorStand) hologram.getArmorStand(hologram.getArmorStands().size() - 1); EntityArmorStand as; if (lastAs != null) { as = new EntityArmorStand(lastAs.world); as.setInvisible(true); as.setCustomName(message); as.setCustomNameVisible(true); as.setSmall(true); as.setGravity(false); as.setLocation( lastAs.locX, lastAs.locY - hologram.getDistance(), lastAs.locZ, lastAs.yaw, lastAs.pitch); } else { Location loc = hologram.getLocation(); as = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle()); as.setInvisible(true); as.setCustomName(message); as.setCustomNameVisible(true); as.setSmall(true); as.setGravity(false); as.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); } for (Player p : hologram.getPlayers()) { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(as); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } return as; }
@Override public void move(Hologram hologram, Location newLocation) { List<EntityArmorStand> armorStands = new ArrayList<EntityArmorStand>(); for (Object as : hologram.getArmorStands()) armorStands.add((EntityArmorStand) as); int newX = MathHelper.floor(newLocation.getX() * 32.0D); int newZ = MathHelper.floor(newLocation.getZ() * 32.0D); for (Player p : hologram.getPlayers()) { for (int i = 0; i < armorStands.size(); ++i) { EntityArmorStand as = armorStands.get(i); double distance = i * hologram.getDistance(); int newY = MathHelper.floor((newLocation.getY() - distance) * 32.0D); PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport( as.getId(), newX, newY, newZ, (byte) newLocation.getYaw(), (byte) newLocation.getPitch(), false); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); as.setLocation( newLocation.getX(), newLocation.getY() - distance, newLocation.getZ(), newLocation.getYaw(), newLocation.getPitch()); } } }