Skip to content

Commit 4c26915

Browse files
Fix text display y offset in 1.19.4->1.19.3 (#1128)
1 parent 7c98b75 commit 4c26915

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/rewriter/EntityPacketRewriter1_19_4.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
public final class EntityPacketRewriter1_19_4 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_4To1_19_3> {
4747

48+
private static final double TEXT_DISPLAY_Y_OFFSET = -0.25; // Move emulated armor stands down to match text display height offsets
49+
4850
public EntityPacketRewriter1_19_4(final Protocol1_19_4To1_19_3 protocol) {
4951
super(protocol, Types1_19_3.ENTITY_DATA_TYPES.optionalComponentType, Types1_19_3.ENTITY_DATA_TYPES.booleanType);
5052
}
@@ -78,6 +80,11 @@ public void register() {
7880
}
7981
}
8082

83+
final double y = wrapper.get(Types.DOUBLE, 1);
84+
if (entityType == EntityTypes1_19_4.TEXT_DISPLAY.getId()) {
85+
wrapper.set(Types.DOUBLE, 1, y + TEXT_DISPLAY_Y_OFFSET);
86+
}
87+
8188
// First track (and remap) entity, then put storage for block display entity
8289
getSpawnTrackerWithDataHandler1_19(EntityTypes1_19_4.FALLING_BLOCK).handle(wrapper);
8390
if (entityType != EntityTypes1_19_4.BLOCK_DISPLAY.getId()) {
@@ -88,7 +95,6 @@ public void register() {
8895
if (data != null) {
8996
final LinkedEntityStorage storage = new LinkedEntityStorage();
9097
final double x = wrapper.get(Types.DOUBLE, 0);
91-
final double y = wrapper.get(Types.DOUBLE, 1);
9298
final double z = wrapper.get(Types.DOUBLE, 2);
9399
storage.setPosition(x, y, z);
94100
data.put(storage);
@@ -183,7 +189,7 @@ public void register() {
183189
wrapper.passthrough(Types.VAR_INT); // Effect id
184190
wrapper.passthrough(Types.BYTE); // Amplifier
185191

186-
// Handle inifinite duration. Use a value the client still accepts without bugging out the display while still being practically infinite
192+
// Handle infinite duration. Use a value the client still accepts without bugging out the display while still being practically infinite
187193
final int duration = wrapper.read(Types.VAR_INT);
188194
wrapper.write(Types.VAR_INT, duration == -1 ? 999999 : duration);
189195
});
@@ -198,11 +204,14 @@ public void register() {
198204
final double z = wrapper.passthrough(Types.DOUBLE);
199205

200206
final EntityTracker1_19_4 tracker = tracker(wrapper.user());
207+
if (tracker.entityType(entityId) == EntityTypes1_19_4.TEXT_DISPLAY) {
208+
wrapper.set(Types.DOUBLE, 1, y + TEXT_DISPLAY_Y_OFFSET);
209+
}
210+
201211
final LinkedEntityStorage storage = tracker.linkedEntityStorage(entityId);
202-
if (storage == null) {
203-
return;
212+
if (storage != null) {
213+
storage.setPosition(x, y, z);
204214
}
205-
storage.setPosition(x, y, z);
206215
});
207216

208217
final PacketHandler entityPositionHandler = wrapper -> {
@@ -213,10 +222,9 @@ public void register() {
213222

214223
final EntityTracker1_19_4 tracker = tracker(wrapper.user());
215224
final LinkedEntityStorage storage = tracker.linkedEntityStorage(entityId);
216-
if (storage == null) {
217-
return;
225+
if (storage != null) {
226+
storage.addRelativePosition(x, y, z);
218227
}
219-
storage.addRelativePosition(x, y, z);
220228
};
221229

222230
protocol.registerClientbound(ClientboundPackets1_19_4.MOVE_ENTITY_POS, entityPositionHandler);

0 commit comments

Comments
 (0)