From 5fd31aece807dc39e496eb066fe691810d76bcd0 Mon Sep 17 00:00:00 2001 From: Thoronium <107363768+NotThorny@users.noreply.github.com> Date: Mon, 11 Sep 2023 23:07:17 -0600 Subject: [PATCH] Fix home nulls (#2355) * Add null checking * Sanity check for moduleManager --- .../grasscutter/game/home/HomeModuleManager.java | 13 +++++++++++++ .../java/emu/grasscutter/game/home/HomeWorld.java | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java index c739c077e..26460c09b 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java +++ b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java @@ -41,12 +41,20 @@ public class HomeModuleManager { } public void tick() { + if (this.moduleId == 0) { + return; + } + this.outdoor.onTick(); this.indoor.onTick(); this.summonEvents.removeIf(HomeAvatarSummonEvent::isTimeOver); } public void refreshMainHouse() { + if (this.moduleId == 0) { + return; + } + this.indoor = this.homeWorld.getSceneById(this.homeWorld.getActiveIndoorSceneId()); } @@ -67,6 +75,7 @@ public class HomeModuleManager { var suites = allBlockItems.stream() .map(HomeBlockItem::getSuiteList) + .filter(Objects::nonNull) .flatMap(Collection::stream) .distinct() .toList(); @@ -210,6 +219,10 @@ public class HomeModuleManager { } public void onSetModule() { + if (this.moduleId == 0) { + return; + } + this.outdoor.addEntities(this.getOutdoorSceneItem().getAnimals(this.outdoor)); this.indoor.addEntities(this.getIndoorSceneItem().getAnimals(this.indoor)); this.fireAllAvatarRewardEvent(); diff --git a/src/main/java/emu/grasscutter/game/home/HomeWorld.java b/src/main/java/emu/grasscutter/game/home/HomeWorld.java index 73718925f..525da1be4 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeWorld.java +++ b/src/main/java/emu/grasscutter/game/home/HomeWorld.java @@ -29,6 +29,9 @@ public class HomeWorld extends World { @Override public boolean onTick() { + if (this.moduleManager == null) { + return false; + } this.moduleManager.tick(); if (this.getTickCount() % 10 == 0) {