Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import com.github.retrooper.packetevents.protocol.world.Location;
import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.meta.other.ArmorStandMeta;
import me.tofaa.entitylib.utils.Check;
import me.tofaa.entitylib.wrapper.WrapperEntity;
Expand All @@ -18,8 +17,8 @@ final class LegacyHologram implements Hologram.Legacy {

private Location location;
private final List<WrapperEntity> lines = new ArrayList<>(3);
private float lineOffset = -0.9875f;
private float markerOffset = -0.40625f;
private float lineOffset = -0.3f;
private float markerOffset = -0.25f;
private boolean marker;
private boolean spawned = false;

Expand Down Expand Up @@ -119,6 +118,13 @@ public boolean isMarker() {
@Override
public void setMarker(boolean marker) {
this.marker = marker;
for (WrapperEntity line : lines) {
ArmorStandMeta meta = (ArmorStandMeta) line.getEntityMeta();
meta.setMarker(marker);
}
if (spawned) {
teleport(location);
}
}

@Override
Expand All @@ -141,26 +147,21 @@ public void hide() {
@Override
public void teleport(Location location) {
this.location = location;
for (int i = lines.size() - 1; i >= 0; i--) {
for (int i = 0; i < lines.size(); i++) {
WrapperEntity line = lines.get(i);
if (!line.isSpawned()) {
line.spawn(location);
spawned = true;
}
double y;
if (marker) {
y = location.getY() + markerOffset;
y = location.getY() + (i * markerOffset);
} else {
y = location.getY() + (i * lineOffset);
}
ArmorStandMeta meta = (ArmorStandMeta) line.getEntityMeta();
meta.setMarker(marker);
Location l = new Location(location.getX(), y, location.getZ(), location.getYaw(), location.getPitch());
line.teleport(l, false);
}
if (spawned) {
setParent(getEntity());
}
}

@Override
Expand All @@ -173,8 +174,12 @@ public void teleport(Location location) {

@Override
public void setLine(int index, @Nullable Component line) {
if (index >= 0 && index < lines.size()) {
ArmorStandMeta meta = (ArmorStandMeta) lines.get(index).getEntityMeta();
meta.setCustomName(line);
return;
}
WrapperEntity e = new WrapperEntity(EntityTypes.ARMOR_STAND);
e.spawn(location);
ArmorStandMeta meta = (ArmorStandMeta) e.getEntityMeta();
meta.setCustomName(line);
meta.setCustomNameVisible(true);
Expand All @@ -183,8 +188,10 @@ public void setLine(int index, @Nullable Component line) {
meta.setSmall(true);
meta.setMarker(marker);
Check.arrayLength(lines, index, e);
e.spawn(location);
teleport(location);
if (spawned) {
e.spawn(location);
teleport(location);
}
}

@Override
Expand All @@ -194,6 +201,9 @@ public void removeLine(int index) {
}
this.lines.get(index).remove();
this.lines.remove(index);
if (spawned && !lines.isEmpty()) {
teleport(location);
}
}

@Override
Expand Down Expand Up @@ -223,18 +233,10 @@ public void setLineOffset(boolean marker, float value) {
@Override
public void setParent(@NotNull WrapperEntity parent) {
if (lines.isEmpty()) return;

WrapperEntity first = lines.get(0);
for (WrapperEntity e : lines) {
if (e.getUuid().equals(first.getUuid())) continue;
try {
first.addPassenger(e);
} catch (Exception ignored) {}
}
if (!first.getUuid().equals(parent.getUuid())) {
try {
parent.addPassenger(first);
} catch (Exception ignored) {}
parent.addPassenger(first);
}
Comment on lines 234 to 240
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Parent-following regresses to a single line.

setParent() now attaches only lines.get(0) and does not retain the parent anywhere. Compared with ModernHologram.setParent() in api/src/main/java/me/tofaa/entitylib/wrapper/hologram/ModernHologram.java:72-87, the rest of the hologram is never rebound after show(), setLine(), or removeLine(). If the parent moves, or the first line is replaced/removed, the remaining lines can be left behind. Please persist the parent and reapply whatever follow mechanism replaces the old passenger chain after structural updates.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/main/java/me/tofaa/entitylib/wrapper/hologram/LegacyHologram.java`
around lines 234 - 240, LegacyHologram.setParent currently only attaches
lines.get(0) and does not store the parent, causing other lines to stop
following after show()/setLine()/removeLine(); change LegacyHologram to persist
the parent reference (e.g., a private WrapperEntity parent field) when
setParent(WrapperEntity) is called, attach the whole passenger chain similarly
to ModernHologram.setParent (rebind all existing lines to follow the parent, not
just lines.get(0)), and ensure show(), setLine(), and removeLine() reapply the
follow/attach logic from the stored parent so updates maintain the binding for
all lines.

}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val fullVersion = "3.2.2"
val fullVersion = "3.2.3"
val snapshot = true

group = "io.github.tofaa2"
Expand Down