Fix home nulls (#2355)

* Add null checking

* Sanity check for moduleManager
This commit is contained in:
Thoronium 2023-09-11 23:07:17 -06:00 committed by GitHub
parent 8de281d4da
commit 5fd31aece8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -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();

View File

@ -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) {