make npc move command work across worlds
This commit is contained in:
parent
f933f17e45
commit
993127ed85
2 changed files with 7 additions and 1 deletions
|
@ -27,6 +27,7 @@ public class MoveCommand implements CommandHandler {
|
|||
Player player = context.ensureSenderIsPlayer();
|
||||
NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc();
|
||||
npc.setLocation(new NpcLocation(player.getLocation()));
|
||||
if (!npc.getWorld().equals(player.getWorld())) npc.setWorld(player.getWorld());
|
||||
context.send(Component.text("NPC moved to your current location.", NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class NpcImpl extends Viewable implements Npc {
|
||||
private final PacketFactory packetFactory;
|
||||
private final String worldName;
|
||||
private String worldName;
|
||||
private PacketEntity entity;
|
||||
private NpcLocation location;
|
||||
private NpcTypeImpl type;
|
||||
|
@ -196,4 +196,9 @@ public class NpcImpl extends Viewable implements Npc {
|
|||
public int getPacketEntityId() {
|
||||
return entity.getEntityId();
|
||||
}
|
||||
|
||||
public void setWorld(World world) {
|
||||
delete();
|
||||
this.worldName = world.getName();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue