-
Notifications
You must be signed in to change notification settings - Fork 1
Tick Time Expensive with StellarFarmlandBlock#isStarlit #10
Copy link
Copy link
Open
Description
Specs
Mod Version: neoforge-mc1.21.1-0.2.0.3
Neoforge Version: 21.1.219
Side: Dedicated Server
Description
I'm getting a good amount of compute taken up by NaturalSpawnerMixin and what it invokes, despite having very few mob spawns:
Lines 25 to 40 in 360a88e
| private static void operation_starcleave$starlitAreasSpawnOverride(ServerLevel level, StructureManager structureManager, ChunkGenerator generator, MobCategory category, BlockPos pos, Holder<Biome> biome, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir) { | |
| Firmament firmament = Firmament.fromLevel(level); | |
| if (firmament != null) { | |
| if (StellarFarmlandBlock.isStarlit(level, pos, firmament)) { | |
| switch(category) { | |
| case MONSTER: | |
| cir.setReturnValue(FirmamentMobSpawning.STARLIGHT_MONSTERS); | |
| break; | |
| case CREATURE: | |
| case AMBIENT: | |
| cir.setReturnValue(FirmamentMobSpawning.NOSPAWNS); | |
| break; | |
| } | |
| } | |
| } | |
| } |
Here's the relevant section of the Spark report:
Suggested Fix
Looking at the code, I don't see any major optimization pitfalls. Something you might want to look into is saving the damage as a "potential field", though I'm pretty sure that would only save on memory and not compute time.
I think some caching, so it doesn't re-check blocks that have been checked already, is all it needs to fix the issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels