Add /npc collidable for players colliding with entities

This commit is contained in:
fullwall 2016-03-20 17:33:41 +08:00
parent 7daf2ccea3
commit bc8e3128fa
4 changed files with 25 additions and 0 deletions

View File

@ -253,6 +253,22 @@ public class NPCCommands {
} }
} }
@Command(
aliases = { "npc" },
usage = "collidable",
desc = "Copies an NPC",
modifiers = { "copy" },
min = 1,
max = 1,
permission = "citizens.npc.collidable")
@Requirements(ownership = true, selected = true, types = { EntityType.PLAYER })
public void collidable(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
npc.data().setPersistent(NPC.COLLIDABLE_METADATA, !npc.data().get(NPC.COLLIDABLE_METADATA, true));
Messaging.sendTr(sender,
npc.data().get(NPC.COLLIDABLE_METADATA) ? Messages.COLLIDABLE_SET : Messages.COLLIDABLE_UNSET,
npc.getName());
}
@Command( @Command(
aliases = { "npc" }, aliases = { "npc" },
usage = "controllable|control (-m(ount),-y,-n,-o)", usage = "controllable|control (-m(ount),-y,-n,-o)",

View File

@ -264,6 +264,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }
@Override
public boolean isCollidable() {
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
}
public boolean isNavigating() { public boolean isNavigating() {
return npc.getNavigator().isNavigating(); return npc.getNavigator().isNavigating();
} }

View File

@ -32,6 +32,8 @@ public class Messages {
public static final String CITIZENS_SAVING = "citizens.notifications.saving"; public static final String CITIZENS_SAVING = "citizens.notifications.saving";
public static final String COLLAR_COLOUR_NOT_RECOGNISED = "citizens.commands.npc.wolf.unknown-collar-color"; public static final String COLLAR_COLOUR_NOT_RECOGNISED = "citizens.commands.npc.wolf.unknown-collar-color";
public static final String COLLAR_COLOUR_NOT_SUPPORTED = "citizens.commands.npc.wolf.collar-color-unsupported"; public static final String COLLAR_COLOUR_NOT_SUPPORTED = "citizens.commands.npc.wolf.collar-color-unsupported";
public static final String COLLIDABLE_SET = "citizens.commands.npc.collidable.set";
public static final String COLLIDABLE_UNSET = "citizens.commands.npc.collidable.unset";
public static final String COMMAND_AGE_HELP = "citizens.commands.npc.age.help"; public static final String COMMAND_AGE_HELP = "citizens.commands.npc.age.help";
public static final String COMMAND_HELP_HEADER = "citizens.commands.help.header"; public static final String COMMAND_HELP_HEADER = "citizens.commands.help.header";
public static final String COMMAND_INVALID_MOBTYPE = "citizens.commands.invalid-mobtype"; public static final String COMMAND_INVALID_MOBTYPE = "citizens.commands.invalid-mobtype";

View File

@ -25,6 +25,8 @@ citizens.commands.npc.anchor.removed=Anchor removed.
citizens.commands.npc.behaviour.added=Behaviours added. citizens.commands.npc.behaviour.added=Behaviours added.
citizens.commands.npc.behaviour.help=The scripts argument is a comma-separated list of file names. Scripts will be loaded automatically and run every tick. Use the [[-r]] flag to remove behaviours. citizens.commands.npc.behaviour.help=The scripts argument is a comma-separated list of file names. Scripts will be loaded automatically and run every tick. Use the [[-r]] flag to remove behaviours.
citizens.commands.npc.behaviour.removed=Behaviours removed. citizens.commands.npc.behaviour.removed=Behaviours removed.
citizens.commands.npc.collidable.set=[[{0}]] will now collide with entities.
citizens.commands.npc.collidable.unset=[[{0}]] will no longer collide with entities.
citizens.commands.npc.controllable.not-controllable=[[{0}]] is not controllable. citizens.commands.npc.controllable.not-controllable=[[{0}]] is not controllable.
citizens.commands.npc.controllable.removed=[[{0}]] can no longer be controlled. citizens.commands.npc.controllable.removed=[[{0}]] can no longer be controlled.
citizens.commands.npc.controllable.set=[[{0}]] can now be controlled. citizens.commands.npc.controllable.set=[[{0}]] can now be controlled.