diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 4cff1725..cc82a737 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -486,6 +486,9 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar // 4J Stu - We call update players when the entity has moved more than a certain amount at the start of it's tick // Before this call we set xpu, ypu and zpu to the entities new position, but xp,yp and zp are the old position until later in the tick. // Therefore we should use the new position for visibility checks + // nullptr check + if (!this || !tracker || !sp) return eVisibility_NotVisible; + if (sp == nullptr) return eVisibility_NotVisible; double xd = sp->x - xpu; //xp / 32; double zd = sp->z - zpu; //zp / 32; @@ -516,6 +519,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar if (!bVisible) #endif { + if (!e || !e->riding) return eVisibility_NotVisible; MinecraftServer *server = MinecraftServer::getInstance(); INetworkPlayer *thisPlayer = sp->connection->getNetworkPlayer(); if( thisPlayer ) @@ -524,6 +528,9 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar { // Consider extra players, but not if they are the entity we are tracking, or the player we've been passed as input, or in another dimension shared_ptr ep = server->getPlayers()->players[i]; + if (!ep) continue; + if (!ep->connection) continue; + if (!ep->connection->getNetworkPlayer()) continue; if( ep == sp ) continue; if( ep == e ) continue; if( ep->dimension != sp->dimension ) continue; diff --git a/Minecraft.World/BonusChestFeature.cpp b/Minecraft.World/BonusChestFeature.cpp index 86dc9725..50e74540 100644 --- a/Minecraft.World/BonusChestFeature.cpp +++ b/Minecraft.World/BonusChestFeature.cpp @@ -24,6 +24,12 @@ bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z) bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z, bool force) { + // check if level is corrupted first + if (level == nullptr || random == nullptr) + { + return false; + } + if (!level->isNew) return false; //Will only spawn a bonus chest if the world is new and has never been saved. if (level->isNew) {