Use separate view range for item and text lines

This commit is contained in:
filoghost 2022-05-29 16:44:10 +02:00
parent 370eb9806f
commit 5727de44dc
4 changed files with 19 additions and 6 deletions

View File

@ -140,4 +140,9 @@ public class ItemLineTracker extends ClickableLineTracker<Viewer> {
}
}
@Override
protected double getViewRange() {
return 16;
}
}

View File

@ -61,8 +61,11 @@ public abstract class LineTracker<T extends Viewer> {
sendChangesPackets = true;
}
if (hasViewers() && updatePlaceholders()) {
sendChangesPackets = true;
if (hasViewers()) {
boolean textChanged = updatePlaceholders();
if (textChanged) {
sendChangesPackets = true;
}
}
// Then, send the changes (if any) to already tracked players

View File

@ -15,8 +15,6 @@ import java.util.Objects;
abstract class PositionBasedLineTracker<T extends Viewer> extends LineTracker<T> {
private static final int ENTITY_VIEW_RANGE = 64;
protected PositionCoordinates position;
private boolean positionChanged;
@ -50,8 +48,8 @@ abstract class PositionBasedLineTracker<T extends Viewer> extends LineTracker<T>
double diffX = Math.abs(playerLocation.getX() - position.getX());
double diffZ = Math.abs(playerLocation.getZ() - position.getZ());
return diffX <= (double) ENTITY_VIEW_RANGE
&& diffZ <= (double) ENTITY_VIEW_RANGE
return diffX <= getViewRange()
&& diffZ <= getViewRange()
&& getLine().isVisibleTo(player.getBukkitPlayer());
}
@ -65,4 +63,6 @@ abstract class PositionBasedLineTracker<T extends Viewer> extends LineTracker<T>
protected abstract void sendPositionChangePackets(Viewers<T> viewers);
protected abstract double getViewRange();
}

View File

@ -114,4 +114,9 @@ public class TextLineTracker extends ClickableLineTracker<TextLineViewer> {
viewers.sendPackets(textEntity.newTeleportPackets(position));
}
@Override
protected double getViewRange() {
return 64;
}
}