diff --git a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java index 26460c09b..d25a3b788 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java +++ b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java @@ -59,11 +59,11 @@ public class HomeModuleManager { } public void onUpdateArrangement() { - this.fireAllAvatarRewardEvent(); - this.cancelSummonEventIfAvatarLeave(); + this.fireAllAvatarRewardEvents(); + this.cancelSummonEventsIfAvatarLeave(); } - private void fireAllAvatarRewardEvent() { + private void fireAllAvatarRewardEvents() { this.rewardEvents.clear(); var allBlockItems = Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem()) @@ -111,7 +111,7 @@ public class HomeModuleManager { } } - private void cancelSummonEventIfAvatarLeave() { + private void cancelSummonEventsIfAvatarLeave() { var avatars = Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem()) .map(HomeSceneItem::getBlockItems) @@ -225,10 +225,14 @@ public class HomeModuleManager { this.outdoor.addEntities(this.getOutdoorSceneItem().getAnimals(this.outdoor)); this.indoor.addEntities(this.getIndoorSceneItem().getAnimals(this.indoor)); - this.fireAllAvatarRewardEvent(); + this.fireAllAvatarRewardEvents(); } public void onRemovedModule() { + if (this.moduleId == 0) { + return; + } + this.outdoor.getEntities().clear(); this.indoor.getEntities().clear(); } diff --git a/src/main/java/emu/grasscutter/game/home/HomeWorld.java b/src/main/java/emu/grasscutter/game/home/HomeWorld.java index c98e93c22..343123d34 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeWorld.java +++ b/src/main/java/emu/grasscutter/game/home/HomeWorld.java @@ -11,13 +11,15 @@ import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.PacketDelTeamEntityNotify; import emu.grasscutter.server.packet.send.PacketPlayerChatNotify; import emu.grasscutter.server.packet.send.PacketPlayerGameTimeNotify; -import java.util.List; -import java.util.function.Consumer; import lombok.Getter; +import java.util.List; +import java.util.function.Consumer; + +@Getter public class HomeWorld extends World { - @Getter private final GameHome home; - @Getter private HomeModuleManager moduleManager; + private final GameHome home; + private HomeModuleManager moduleManager; public HomeWorld(GameServer server, Player owner) { super(server, owner); @@ -60,7 +62,11 @@ public class HomeWorld extends World { } public int getActiveIndoorSceneId() { - return this.getSceneById(this.getActiveOutdoorSceneId()).getSceneItem().getRoomSceneId(); + return this.isRealmIdValid() ? this.getSceneById(this.getActiveOutdoorSceneId()).getSceneItem().getRoomSceneId() : -1; + } + + public boolean isRealmIdValid() { + return this.getHost().getCurrentRealmId() > 0; } @Override diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChooseModuleReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChooseModuleReq.java index f6748c238..d5a4feefc 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChooseModuleReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeChooseModuleReq.java @@ -14,6 +14,7 @@ public class HandlerHomeChooseModuleReq extends PacketHandler { HomeChooseModuleReqOuterClass.HomeChooseModuleReq.parseFrom(payload); session.getPlayer().addRealmList(req.getModuleId()); session.getPlayer().setCurrentRealmId(req.getModuleId()); + session.getPlayer().getCurHomeWorld().refreshModuleManager(); session.send(new PacketHomeChooseModuleRsp(req.getModuleId())); session.send(new PacketPlayerHomeCompInfoNotify(session.getPlayer())); session.send(new PacketHomeComfortInfoNotify(session.getPlayer()));