@Override public void setDistance(Hologram hologram, double distance) { List<EntityArmorStand> armorStands = new ArrayList<EntityArmorStand>(); Location loc = hologram.getLocation(); for (Object as : hologram.getArmorStands()) armorStands.add((EntityArmorStand) as); for (Player p : hologram.getPlayers()) { for (int i = 1; i < armorStands.size(); ++i) { EntityArmorStand beforeAs = armorStands.get(i - 1); EntityArmorStand as = armorStands.get(i); int newX = MathHelper.floor(loc.getX() * 32.0D); int newY = MathHelper.floor((beforeAs.locY - distance) * 32.0D); int newZ = MathHelper.floor(loc.getZ() * 32.0D); PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport( as.getId(), newX, newY, newZ, (byte) as.yaw, (byte) as.pitch, false); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); as.setLocation(as.locX, beforeAs.locY - distance, as.locZ, as.yaw, as.pitch); } } }
@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; }