Add support for formatted names in create_marker (#1413)

This commit is contained in:
altrisi authored and GitHub committed 2022-04-20 13:01:58 +02:00
1 parent b6fa6579ae
commit 76861479e0
1 file changed
+5 -5
@@ -341,11 +341,11 @@ public class Auxiliary {
BlockState targetBlock = null; BlockState targetBlock = null;
Vector3Argument pointLocator; Vector3Argument pointLocator;
boolean interactable = true; boolean interactable = true;
String name; Component name;
try try
{ {
Value nameValue = lv.get(0); Value nameValue = lv.get(0);
name = nameValue.isNull() ? "" : nameValue.getString(); name = nameValue.isNull() ? null : FormattedTextValue.getTextByValue(nameValue);
pointLocator = Vector3Argument.findIn(lv, 1, true, false); pointLocator = Vector3Argument.findIn(lv, 1, true, false);
if (lv.size()>pointLocator.offset) if (lv.size()>pointLocator.offset)
{ {
@@ -364,7 +364,7 @@ public class Auxiliary {
ArmorStand armorstand = new ArmorStand(EntityType.ARMOR_STAND, cc.s.getLevel()); ArmorStand armorstand = new ArmorStand(EntityType.ARMOR_STAND, cc.s.getLevel());
double yoffset; double yoffset;
if (targetBlock == null && name.isEmpty()) if (targetBlock == null && name == null)
{ {
yoffset = 0.0; yoffset = 0.0;
} }
@@ -395,9 +395,9 @@ public class Auxiliary {
armorstand.addTag(MARKER_STRING); armorstand.addTag(MARKER_STRING);
if (targetBlock != null) if (targetBlock != null)
armorstand.setItemSlot(EquipmentSlot.HEAD, new ItemStack(targetBlock.getBlock().asItem())); armorstand.setItemSlot(EquipmentSlot.HEAD, new ItemStack(targetBlock.getBlock().asItem()));
if (!name.isEmpty()) if (name != null)
{ {
armorstand.setCustomName(new TextComponent(name)); armorstand.setCustomName(name);
armorstand.setCustomNameVisible(true); armorstand.setCustomNameVisible(true);
} }
armorstand.setHeadPose(new Rotations((int)pointLocator.pitch,0,0)); armorstand.setHeadPose(new Rotations((int)pointLocator.pitch,0,0));