Skip to content

Commit a201ae3

Browse files
committed
Support packet text displays on Paper 26.2
1 parent ed2d99d commit a201ae3

4 files changed

Lines changed: 39 additions & 5 deletions

File tree

common/src/main/java/com/loohp/interactionvisualizer/integration/packet/ClientTextDisplayBridge.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import net.momirealms.sparrow.heart.util.SelfIncreaseEntityID;
1717
import org.bukkit.Bukkit;
1818
import org.bukkit.Location;
19+
import org.bukkit.entity.EntityType;
1920
import org.bukkit.entity.Player;
2021

2122
import java.lang.reflect.Constructor;
@@ -241,7 +242,14 @@ private static Resolution resolve() {
241242

242243
Class<?> entityTypeClass = Class.forName(
243244
"net.minecraft.world.entity.EntityType", false, serverLoader);
244-
Object textDisplayEntityType = entityTypeClass.getField("TEXT_DISPLAY").get(null);
245+
Class<?> craftEntityTypeClass = Class.forName(
246+
"org.bukkit.craftbukkit.entity.CraftEntityType", false, serverLoader);
247+
Method bukkitToMinecraft = craftEntityTypeClass.getMethod(
248+
"bukkitToMinecraft", EntityType.class);
249+
Object textDisplayEntityType = bukkitToMinecraft.invoke(null, EntityType.TEXT_DISPLAY);
250+
if (!entityTypeClass.isInstance(textDisplayEntityType)) {
251+
throw new IllegalStateException("CraftEntityType returned an invalid text-display entity type");
252+
}
245253
Class<?> vec3Class = Class.forName(
246254
"net.minecraft.world.phys.Vec3", false, serverLoader);
247255
Constructor<?> vec3Constructor = vec3Class.getConstructor(

common/src/test/java/com/loohp/interactionvisualizer/integration/packet/ClientTextDisplayBridgeTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import net.minecraft.network.syncher.SynchedEntityData;
2121
import net.minecraft.server.level.ServerPlayer;
2222
import net.minecraft.server.network.ServerGamePacketListenerImpl;
23-
import net.minecraft.world.entity.EntityType;
2423
import net.minecraft.world.phys.Vec3;
2524
import org.bukkit.Bukkit;
2625
import org.bukkit.Location;
@@ -94,7 +93,7 @@ void bundlesSpawnWithTheCompleteLegacyNameTagProfile() {
9493
assertEquals(12.0F, add.xRot());
9594
assertEquals(90.0F, add.yRot());
9695
assertEquals(90.0, add.yHeadRot());
97-
assertSame(EntityType.TEXT_DISPLAY, add.type());
96+
assertEquals("text_display", add.type().key());
9897
assertSame(Vec3.ZERO, add.movement());
9998

10099
ClientboundSetEntityDataPacket metadata = assertInstanceOf(

common/src/test/java/net/minecraft/world/entity/EntityType.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
package net.minecraft.world.entity;
1313

1414
public record EntityType<T>(String key) {
15-
16-
public static final EntityType<Object> TEXT_DISPLAY = new EntityType<>("text_display");
1715
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* This file is part of InteractionVisualizer.
3+
*
4+
* Copyright (C) 2026. Contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*/
11+
12+
package org.bukkit.craftbukkit.entity;
13+
14+
import net.minecraft.world.entity.EntityType;
15+
16+
public final class CraftEntityType {
17+
18+
private static final EntityType<Object> TEXT_DISPLAY = new EntityType<>("text_display");
19+
20+
private CraftEntityType() {
21+
}
22+
23+
public static EntityType<?> bukkitToMinecraft(org.bukkit.entity.EntityType type) {
24+
if (type != org.bukkit.entity.EntityType.TEXT_DISPLAY) {
25+
throw new IllegalArgumentException("Unsupported test entity type: " + type);
26+
}
27+
return TEXT_DISPLAY;
28+
}
29+
}

0 commit comments

Comments
 (0)