Holographic Displays

Holographic Displays

3M Downloads

Updating a line without update-lag

manuel-rw opened this issue ยท 1 comments

commented

My goal ist to crate an 3 dimensional menu with floating items & texts in the air.
Each menu item is displayed as an armorstand, with an custom name.
Calculated by following code, i also add a moving hologramm at the top of the players screen:

@EventHandler
    public void onMove(PlayerMoveEvent e) {
        if (warps_cancel.containsKey(e.getPlayer().getName())) {
            Player p = e.getPlayer();
            Hologram holo = hologramms.get(p.getName());
            Vector direction = p.getLocation().getDirection().normalize();
            direction.multiply(2D);
            Location add = p.getLocation().add(direction);
            add.setY(p.getLocation().getY());
            add.add(0,2.8,0);
            holo.teleport(add);
        }
    }

The text of it gets updated by following code:

String next = animationHashMap.get(p.getName()).getContent();
Hologram holo = hologramms.get(p.getName());
holo.clearLines();
holo.insertTextLine(0,next);
animationHashMap.put(p.getName(),animationHashMap.get(p.getName()).getNext());

While removing all lines and finally adding a new one (with the new animation content, provided by the "animationHashMap", it slightly stucks for a few ticks and i wont move by the MoveEvent.
Any suggetions to update the text more smooth, so it wont lag back every time the content is changed?

commented

The solution is probably to update the first line, instead of removing all the lines and adding a new one. Can you try that?