Add some hologram debug

This commit is contained in:
fullwall 2024-08-12 08:04:43 +08:00
parent 57df21d13b
commit f78c87b576
5 changed files with 38 additions and 26 deletions

View File

@ -11,7 +11,7 @@
<artifactId>citizens-main</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.21-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.21.1-R0.1-SNAPSHOT</craftbukkit.version>
<placeholderapi.version>2.11.5</placeholderapi.version>
<citizensapi.version>${project.version}</citizensapi.version>
<worldguard.version>7.1.0-SNAPSHOT</worldguard.version>

View File

@ -829,6 +829,7 @@ public class HologramTrait extends Trait {
if (!Placeholders.containsPlaceholders(raw)) {
hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, Messaging.stripColor(raw).length() > 0);
}
Messaging.idebug(() -> "set hologram name to " + text + " for " + npc);
}
}
@ -890,6 +891,8 @@ public class HologramTrait extends Trait {
if (hologram == null)
return;
hologram.data().set(NPC.Metadata.TEXT_DISPLAY_COMPONENT, Messaging.minecraftComponentFromRawMessage(text));
Messaging.idebug(
() -> "set hologram name to " + Messaging.minecraftComponentFromRawMessage(text) + " for " + npc);
}
}

View File

@ -34,7 +34,7 @@ public class FrogTrait extends Trait {
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Frog && variant != null) {
if (variant != null && npc.getEntity() instanceof Frog) {
Frog frog = (Frog) npc.getEntity();
frog.setVariant(variant);
}

View File

@ -9,7 +9,7 @@
<artifactId>citizens-v1_21_R1</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.21-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.21.1-R0.1-SNAPSHOT</craftbukkit.version>
</properties>
<dependencies>

View File

@ -1200,29 +1200,8 @@ public class NMSImpl implements NMSBridge {
@Override
public InventoryView openAnvilInventory(Player player, Inventory anvil, String title) {
ServerPlayer handle = (ServerPlayer) getHandle(player);
final AnvilMenu container = new AnvilMenu(handle.nextContainerCounter(), handle.getInventory(),
ContainerLevelAccess.create(handle.level(), new BlockPos(0, 0, 0))) {
private CraftAnvilView bukkitEntity;
@Override
protected void clearContainer(net.minecraft.world.entity.player.Player entityhuman, Container iinventory) {
}
@Override
public void createResult() {
super.createResult();
cost.set(0);
}
@Override
public CraftAnvilView getBukkitView() {
if (this.bukkitEntity == null) {
this.bukkitEntity = new CraftAnvilView(this.player.getBukkitEntity(), new CitizensInventoryAnvil(
this.access.getLocation(), this.inputSlots, this.resultSlots, this, anvil), this);
}
return this.bukkitEntity;
}
};
CitizensAnvilMenu container = new CitizensAnvilMenu(handle.nextContainerCounter(), handle.getInventory(),
ContainerLevelAccess.create(handle.level(), new BlockPos(0, 0, 0)), anvil);
container.setTitle(MutableComponent.create(new LiteralContents(title == null ? "" : title)));
container.getBukkitView().setItem(0, anvil.getItem(0));
container.getBukkitView().setItem(1, anvil.getItem(1));
@ -1920,6 +1899,36 @@ public class NMSImpl implements NMSBridge {
}
}
private final class CitizensAnvilMenu extends AnvilMenu {
private final Inventory anvil;
private CraftAnvilView bukkitEntity;
private CitizensAnvilMenu(int i, net.minecraft.world.entity.player.Inventory playerinventory,
ContainerLevelAccess containeraccess, Inventory anvil) {
super(i, playerinventory, containeraccess);
this.anvil = anvil;
}
@Override
protected void clearContainer(net.minecraft.world.entity.player.Player entityhuman, Container iinventory) {
}
@Override
public void createResult() {
super.createResult();
cost.set(0);
}
@Override
public CraftAnvilView getBukkitView() {
if (this.bukkitEntity == null) {
this.bukkitEntity = new CraftAnvilView(this.player.getBukkitEntity(), new CitizensInventoryAnvil(
this.access.getLocation(), this.inputSlots, this.resultSlots, this, anvil), this);
}
return this.bukkitEntity;
}
}
private static class CitizensInventoryAnvil extends CraftInventoryAnvil implements ForwardingInventory {
private final Inventory wrapped;