Add glowing for non-player characters, stop 1.8.8 noDamageTicks from going down too fast

This commit is contained in:
fullwall 2022-02-15 01:35:07 +08:00
parent a29fb3059a
commit bf56a6dcb2
3 changed files with 5 additions and 11 deletions

View File

@ -816,8 +816,6 @@ public class NPCCommands {
public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (args.hasValueFlag("color")) {
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
if (!(npc.getEntity() instanceof Player))
throw new CommandException(Messages.GLOWING_COLOR_PLAYER_ONLY);
npc.getOrAddTrait(ScoreboardTrait.class).setColor(chatColor);
if (!npc.data().has(NPC.GLOWING_METADATA)) {
npc.data().setPersistent(NPC.GLOWING_METADATA, true);
@ -2518,11 +2516,13 @@ public class NPCCommands {
public void useitem(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
boolean offhand = args.hasFlag('o');
if (offhand) {
npc.data().set(NPC.Metadata.USING_OFFHAND_ITEM, !npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM, false));
npc.data().setPersistent(NPC.Metadata.USING_OFFHAND_ITEM,
!npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM, false));
Messaging.sendTr(sender, Messages.TOGGLED_USING_OFFHAND_ITEM,
npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM));
} else {
npc.data().set(NPC.Metadata.USING_HELD_ITEM, !npc.data().get(NPC.Metadata.USING_HELD_ITEM, false));
npc.data().setPersistent(NPC.Metadata.USING_HELD_ITEM,
!npc.data().get(NPC.Metadata.USING_HELD_ITEM, false));
Messaging.sendTr(sender, Messages.TOGGLED_USING_HELD_ITEM, npc.data().get(NPC.Metadata.USING_HELD_ITEM));
}
}

View File

@ -427,8 +427,7 @@ public class CitizensNPC extends AbstractNPC {
String teamName = data().get(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME, "");
Team team = null;
if (!(getEntity() instanceof Player) || teamName.length() == 0
|| (team = Util.getDummyScoreboard().getTeam(teamName)) == null)
if (teamName.length() == 0 || (team = Util.getDummyScoreboard().getTeam(teamName)) == null)
return;
if (!Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
@ -436,7 +435,6 @@ public class CitizensNPC extends AbstractNPC {
data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
return;
}
getOrAddTrait(ScoreboardTrait.class).apply(team, nameVisibility);
}

View File

@ -402,10 +402,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
boolean navigating = npc.getNavigator().isNavigating();
updatePackets(navigating);
if (noDamageTicks > 0) {
--noDamageTicks;
}
npc.update();
}