mirror of
https://github.com/YouHaveTrouble/NotJustNameplates.git
synced 2026-05-11 22:16:57 +00:00
mostly fix interpolation
This commit is contained in:
@@ -29,6 +29,7 @@ public class Nameplate {
|
|||||||
|
|
||||||
protected boolean forceHide = false;
|
protected boolean forceHide = false;
|
||||||
private DisplayContent content;
|
private DisplayContent content;
|
||||||
|
private DisplayFrame lastFrame;
|
||||||
public final UUID playerUuid;
|
public final UUID playerUuid;
|
||||||
private TextDisplay.TextAlignment alignment = TextDisplay.TextAlignment.CENTER;
|
private TextDisplay.TextAlignment alignment = TextDisplay.TextAlignment.CENTER;
|
||||||
private boolean visibleForOwner = false;
|
private boolean visibleForOwner = false;
|
||||||
@@ -139,15 +140,29 @@ public class Nameplate {
|
|||||||
* Update the nameplate position
|
* Update the nameplate position
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
|
update(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(boolean forceNoInterpolate) {
|
||||||
|
boolean shouldInterpolate = false;
|
||||||
|
|
||||||
if (forceHide) {
|
if (forceHide) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = Bukkit.getPlayer(playerUuid);
|
Player player = Bukkit.getPlayer(playerUuid);
|
||||||
if (player == null || player.isDead()) {
|
if (player == null || player.isDead()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisplayFrame currentFrame = player.isSneaking() && content.getCurrentFrame().sneakOverride() != null ? content.getCurrentFrame().sneakOverride() : content.getCurrentFrame();
|
||||||
|
if (!currentFrame.equals(lastFrame)) {
|
||||||
|
shouldInterpolate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastFrame = currentFrame;
|
||||||
if (player.getGameMode() == GameMode.SPECTATOR) {
|
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
@@ -171,7 +186,7 @@ public class Nameplate {
|
|||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DisplayFrame currentFrame = player.isSneaking() && content.getCurrentFrame().sneakOverride() != null ? content.getCurrentFrame().sneakOverride() : content.getCurrentFrame();
|
|
||||||
if (currentFrame.text() == null) {
|
if (currentFrame.text() == null) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
@@ -179,6 +194,12 @@ public class Nameplate {
|
|||||||
|
|
||||||
createDisplayEntity();
|
createDisplayEntity();
|
||||||
if (textDisplay == null || textDisplay.isDead()) return;
|
if (textDisplay == null || textDisplay.isDead()) return;
|
||||||
|
|
||||||
|
if (shouldInterpolate) {
|
||||||
|
textDisplay.setInterpolationDuration(forceNoInterpolate ? 0 : content.getInterpolationDuration());
|
||||||
|
textDisplay.setInterpolationDelay(forceNoInterpolate ? 0 : content.getInterpolationDelay());
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.getPassengers().contains(textDisplay)) {
|
if (!player.getPassengers().contains(textDisplay)) {
|
||||||
player.addPassenger(textDisplay);
|
player.addPassenger(textDisplay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class NameplateManager implements Listener {
|
|||||||
Nameplate nameplate = nameplates.get(player.getUniqueId());
|
Nameplate nameplate = nameplates.get(player.getUniqueId());
|
||||||
if (nameplate == null) return;
|
if (nameplate == null) return;
|
||||||
if (nameplate.getContent().getCurrentFrame().sneakOverride() == null) return;
|
if (nameplate.getContent().getCurrentFrame().sneakOverride() == null) return;
|
||||||
nameplate.update();
|
nameplate.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadNameplates() {
|
public void reloadNameplates() {
|
||||||
|
|||||||
Reference in New Issue
Block a user