Add /npc hologram direction
This commit is contained in:
parent
2a8f54f2d6
commit
8639c0ab27
|
@ -94,6 +94,7 @@ import net.citizensnpcs.trait.FollowTrait;
|
|||
import net.citizensnpcs.trait.GameModeTrait;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.trait.HologramTrait;
|
||||
import net.citizensnpcs.trait.HologramTrait.HologramDirection;
|
||||
import net.citizensnpcs.trait.HorseModifiers;
|
||||
import net.citizensnpcs.trait.LookClose;
|
||||
import net.citizensnpcs.trait.MountTrait;
|
||||
|
@ -715,7 +716,7 @@ public class NPCCommands {
|
|||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "hologram add [text] | set [line #] [text] | remove [line #] | clear | lineheight [height]",
|
||||
usage = "hologram add [text] | set [line #] [text] | remove [line #] | clear | lineheight [height] | direction [up|down]",
|
||||
desc = "Controls NPC hologram text",
|
||||
modifiers = { "hologram" },
|
||||
min = 1,
|
||||
|
@ -766,6 +767,11 @@ public class NPCCommands {
|
|||
} else if (args.getString(1).equalsIgnoreCase("lineheight")) {
|
||||
trait.setLineHeight(args.getDouble(2));
|
||||
Messaging.sendTr(sender, Messages.HOLOGRAM_LINE_HEIGHT_SET, args.getDouble(2));
|
||||
} else if (args.getString(1).equalsIgnoreCase("direction")) {
|
||||
HologramDirection direction = args.getString(2).equalsIgnoreCase("up") ? HologramDirection.BOTTOM_UP
|
||||
: HologramDirection.TOP_DOWN;
|
||||
trait.setDirection(direction);
|
||||
Messaging.sendTr(sender, Messages.HOLOGRAM_DIRECTION_SET, Util.prettyEnum(direction));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ import net.citizensnpcs.util.NMS;
|
|||
@TraitName("hologramtrait")
|
||||
public class HologramTrait extends Trait {
|
||||
private Location currentLoc;
|
||||
@Persist
|
||||
private HologramDirection direction = HologramDirection.BOTTOM_UP;
|
||||
private final List<NPC> hologramNPCs = Lists.newArrayList();
|
||||
@Persist
|
||||
private double lineHeight = -1;
|
||||
|
@ -58,7 +60,10 @@ public class HologramTrait extends Trait {
|
|||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
hologramNPC.spawn(currentLoc.clone().add(0, getEntityHeight() + heightOffset, 0));
|
||||
hologramNPC.spawn(currentLoc.clone().add(0,
|
||||
getEntityHeight()
|
||||
+ (direction == HologramDirection.BOTTOM_UP ? heightOffset : getMaxHeight() - heightOffset),
|
||||
0));
|
||||
return hologramNPC;
|
||||
}
|
||||
|
||||
|
@ -74,6 +79,11 @@ public class HologramTrait extends Trait {
|
|||
return lines;
|
||||
}
|
||||
|
||||
private double getMaxHeight() {
|
||||
return (lineHeight == -1 ? Setting.DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT.asDouble() : lineHeight)
|
||||
* (lines.size() + (npc.requiresNameHologram() ? 0 : -1));
|
||||
}
|
||||
|
||||
private void load() {
|
||||
currentLoc = npc.getStoredLocation();
|
||||
int i = 0;
|
||||
|
@ -150,6 +160,12 @@ public class HologramTrait extends Trait {
|
|||
}
|
||||
}
|
||||
|
||||
public void setDirection(HologramDirection direction) {
|
||||
this.direction = direction;
|
||||
unload();
|
||||
load();
|
||||
}
|
||||
|
||||
public void setLine(int idx, String text) {
|
||||
lines.set(idx, text);
|
||||
}
|
||||
|
@ -170,4 +186,9 @@ public class HologramTrait extends Trait {
|
|||
}
|
||||
hologramNPCs.clear();
|
||||
}
|
||||
|
||||
public enum HologramDirection {
|
||||
BOTTOM_UP,
|
||||
TOP_DOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ public class Messages {
|
|||
public static final String GUIDED_WAYPOINT_EDITOR_END = "citizens.editors.waypoints.guided.end";
|
||||
public static final String HOLOGRAM_CLEARED = "citizens.commands.npc.hologram.cleared";
|
||||
public static final String HOLOGRAM_DESCRIBE_HEADER = "citizens.commands.npc.hologram.text-describe-header";
|
||||
public static final String HOLOGRAM_DIRECTION_SET = "citizens.commands.npc.hologram.direction-set";
|
||||
public static final String HOLOGRAM_INVALID_LINE = "citizens.commands.npc.hologram.invalid-text-id";
|
||||
public static final String HOLOGRAM_LINE_ADD = "citizens.commands.npc.hologram.line-add";
|
||||
public static final String HOLOGRAM_LINE_HEIGHT_SET = "citizens.commands.npc.hologram.line-height-set";
|
||||
|
|
|
@ -96,6 +96,7 @@ citizens.commands.npc.hologram.text-describe-header=[[{0}]]''s hologram text (in
|
|||
citizens.commands.npc.hologram.invalid-text-id=Invalid line number.
|
||||
citizens.commands.npc.hologram.line-height-set=Line height set to [[{0}]].
|
||||
citizens.commands.npc.hologram.line-removed=Removed line [[{0}]].
|
||||
citizens.commands.npc.hologram.direction-set=Direction set to [[{0}]].
|
||||
citizens.commands.npc.hologram.line-add=Added a new hologram line: [[{0}]].
|
||||
citizens.commands.npc.hologram.cleared=Hologram lines cleared.
|
||||
citizens.commands.npc.horse.chest-set=The horse is now carrying a chest.
|
||||
|
|
Loading…
Reference in New Issue