Hexerei

Hexerei

16M Downloads

[1.18.1] Hexerei version 0.1.12 introduced a lot of worldgen lag. (Profiler included.)

Gbergz opened this issue ยท 10 comments

commented

The version update 0.1.12 made the world a whole lot more laggier when generating landscape than vs v0.1.11.
TPS is dropping a lot when generating land. ("net.minecraft.world.level.Level.getChunk") under Hexerei takes up 43%.

Profiler:
https://spark.lucko.me/xBu5kkbAGD (Click the "All" button almost top right.)

Versions:
Forge: 39.0.19
Minecraft: 1.18.1
Hexerei: v0.1.12 | https://www.curseforge.com/minecraft/mc-mods/hexerei/files/3602103

- Gbergz

commented

I will definitely look into it! Thanks for bringing it to my attention

commented

I also noticed this issue recently. Here's my profiler as well: https://spark.lucko.me/Xy2bl3wQIa

commented

Ok I believe I might have fixed it, basically in that same function before it calls for the tile entities it checks if this is based on chunk generation and if it is it just skips the whole method.

if(e.getSpawnReason() == MobSpawnType.CHUNK_GENERATION)
return;

commented

Some worldgen lag here on latest version https://spark.lucko.me/abRFjXwN8w

commented

I'm also having the issue, but it isn't limited to worldgen. It seems tied to the number of entities being spawned / loaded in my case. When testing we had a player teleport between locations to force the game to begin spawning entities and saw serious lag stemming from hexerei. Here's the profile, bearing in mind we were trying to force the issue: https://spark.lucko.me/Nn5BvxFL8d
We tested on both 0.1.12 & 0.1.13 with the same results.

I think the issue stems primarily from how you've implemented the functionality to find the nearby sage burning plates. Mainly that it (if I'm reading it correctly) iterates across each chunk in radius of a spawn event to determine if a sage plate.is present. Verbally this is presented as "when a mob tries to spawn, load and check all valid blocks in range, and prevent the spawn if there is an active sage plate present". As a result, ALL mob spawn events are dependent on this check, even when no sage plates are present in the world.

I know it would cause a lot of headache to rewrite, but I think a better solution would be to make the sage burning plate prevent mob spawns in the first place. This way the method doesn't trigger every time a hostile mob attempts to spawn, and there is no need to check nearby chunks for sage plates at all. My initial idea for this would be similar to how TorchMaster implemented their mega torches. Given that 1.18 now only allows hostile mobs to spawn in light level 0, would it be possible to make the sage plate set all applicable blocks in radius where light level is 0 to 1? This would have the same effect of preventing hostile mob spawns, but wouldn't require spawning entities to check their surroundings for an active sage plate. There would be a minor cosmetic impact from the light level, but I think you could even lean into it as "added mood".

commented

I did read through how the mega torches acquire this goal but honestly I think its a bit beyond my scope right now, I have absolutely no idea how to implement this. keep in mind that this is my first ever mod and I just started java and modding just 2 days over 3 months ago so there are definitely things out of my scope right now. But I was stupid and I configured it the wrong way in the last update. I could have only prevented mobs from spawning if its only a natural spawn, and before I only checked if it was not generating from loading new chunks. but now (well in the next upcoming update) it will have it ONLY checking mobs on natural spawning otherwise it will just return. and this will mean not checking mobs when teleporting or any other method other than them just spawning for the first time and also not being upon chunk generation

commented

This is somewhat related, I can move to a new issue if you prefer:

Iterator<BlockEntity> iterator = world.getChunk(x, z).getBlockEntities().values().iterator();
getTileEntitiesAroundPosition is calling getChunk with two arguments, this will force the chunk to be loaded if it's not already loaded. This should be checking hasChunk first, to see if the chunk is loaded, so that it's not constantly loading/unloading chunks around an active spawner, for example.

commented

should all be fixed and patched up, if still persists can change to 0 range on the plate and itll take away all calculations

commented

Hey, tried the new update. Without changing anything the problem is still there.
Profiler: https://spark.lucko.me/PvqK1PwVTO

Edit: Setting range in config to 0 still makes it lag, no difference with it default or 0.

commented

that is very strange.. as there is literally an exit code before any of the checking if the range is set to 0. I think there might be something with my configs where they have to be matching on server and world. I am not totally sure but I will look into it, I dont know what I am doing most of the time and just hoping for the best. so any help from people would be appreciated