EnigmaticaModpacks / Enigmatica9

The official repository and issue-tracker for Enigmatica 9
37 stars 57 forks source link

Creatures and Beasts (CNB) Sporeling Bug [Overspawn + Hostile Spawn Bug] #481

Closed KuryKat closed 11 months ago

KuryKat commented 1 year ago

Modpack Version

1.8.1

Describe your issue.

When my friends were playing they told me the CNB's Sporeling was spawning way too much on The Nether, I thought they were exaggerating, but then when I look onto it, it seems like it's true...

(All the white dots on the map are red sporelings) image

Besides... it seems that the Warped Variation, and any of the hostile variations aren't spawning at all.... it only naturally spawns the Red Friendly ones.... image

I have spoken to HellionGames in the Bonsai Studios Discord server and they told me to try this datapack to try to partially reduce the overspawn, since it fixes BYG's biomes so they're actually adding to the Minecraft is_nether tag. Their biomes weren't properly tagged.

/kubejs/data/minecraft/tags/worldgen/biome/is_nether.json

{
  "replace": false,
  "values": [
    "byg:arisian_undergrowth",
    "byg:brimstone_caverns",
    "byg:crimson_gardens",
    "byg:embur_bog",
    "byg:glowstone_gardens",
    "byg:magma_wastes",
    "byg:quartz_desert",
    "byg:subzero_hypogeal",
    "byg:sythian_torrids",
    "byg:wailing_garth",
    "byg:warped_desert",
    "byg:weeping_mire"
  ]
}

After a small testing that I asked the players to do, it seemed to have reduced the first but just a little.

The other problem is that the hostile mob isn't spawning, at all, we tried checking the warped forest and naturally only spawns the red friendly one:

image

which wasn't even supposed to spawn there, with the spawn egg it also spawns the same one:

image

I could only spawn the hostile one with commands:

image

The mod developer himself said that it shouldn't be a mod bug, since it's the first time they see that happening, they said that some mod, or some modification done by the modpack, seems to be overriding the "finalizeSpawn" method behavior for the Sporeling, meaning that none of the variant setting is functioning.

I am not entirely sure this could be a bug in Enigmatica's end to be honest, creating this issue more to track it, to be honest.

Hope we manage to fix this somehow.

Crash Report

No response

Latest Log

No response

Have you modified the modpack?

No

User Modifications

No response

Did the issue happen in singleplayer or on a server?

Both

Discord Username

@KuryKat

Dariensg commented 1 year ago

They pretty much covered everything (I'm the Creatures and Beasts dev). I did want to mention, my suspicion for another mod overriding the behavior of finalizeSpawn comes from a couple of tests. Natural spawning and egg spawning both don't spawn the variants they should, which happens in finalizeSpawn. Especially with egg spawning, but even with natural spawning, this shouldn't happen based on the code. Spawning it with a command setting the variant NBT, however, did work. So there isn't an issue with the data being recognized, just it being set on spawn.

I'll link the relevant method from my repo here.

It's worth noting that the improperly tagged biomes from BYG is a separate, but equally relevant issue. If the spawns are added to a Nether biome with the monster category, but the biome isn't properly tagged as Nether using the Vanilla Minecraft tag, the spawn will spawn the creature variant of Sporelings as was happening here, but they will count to the creature mob cap while checking the monster cap for space, leading to potentially infinite spawns. Note that this isn't entirely what's happening here as the variant is still incorrect in the vanilla Warped Forest biome. Let me know if any more info would help!

theboo commented 1 year ago

yeah, i completely forgot motoko is giving these guys some fun effects through the apotheosis miniboss feature.. this is on us/apotheosis

spawn is being overwritten here(100% chance): https://github.com/EnigmaticaModpacks/Enigmatica9/blob/master/kubejs/server_scripts/base/recipes/apotheosis/minibosses/cnb.js

and the fun effects are here(reactive enchant/ars spells): https://github.com/EnigmaticaModpacks/Enigmatica9/blob/master/kubejs/server_scripts/base/recipes/apotheosis/miniboss_gear/sporeling.js

KuryKat commented 1 year ago

Yeah I saw those scripts but I honestly assumed it wasn't a problem because since they refer to apotheosis bosses I'd assume it'd be when Apotheosis decides to spawn a Sporeling as a boss, you know? but I'm not sure if it's working, we'd need to confirm with @MuteTiefling

Edit: We'd need to ask them if they fully tested it and such, to check if it was working in all scenarios

theboo commented 1 year ago

the minibosses are different than the full bosses... minibosses are the things like the forsaken knights/other custom skeletons... just normal mobs with a chance at spawning with certain effects/attributes... the actual apo boss stuff(the bosses that spawn with a sound and are highlighted in world) is all in apotheosis/bosses, not /minibosses

in that script the chance is set to 1.0, so all sporelings will spawn with one of those two configurations every time, replacing normal sporelings... doubt it was tested with the nether guys.

Dariensg commented 1 year ago

Yeah, that's definitely it. Their variants are stored as NBT, so that script spawning them with a set blank NBT is wiping their variant. I don't know much about scripts in this sense, but if you could take into account their NBT on spawn and incorporate it, that should fix it! Glad it was at least a pretty simple problem to find!

Dariensg commented 1 year ago

It is worth noting that if Sporelings spawns are added to a Nether biome that isn't tagged correctly, it can end up in the infinite spawn issue, but that wouldn't be on you guys. I supplied the OP with a datapack that at least tags the BYG biomes correctly since the Sporelings seemed to be spawning in those, but it's just something to keep in mind in case others run into Sporelings taking over their world in the future.

MuteTiefling commented 1 year ago

Alright, I get why the apotheosis stuff would break the variants, but I'm not sure I understand why they're spawning too much? Is there something wrong with this?

https://github.com/EnigmaticaModpacks/Enigmatica9/blob/ad14e3318aaa9a8a146f32f970a9d5450699404f/kubejs/startup_scripts/base/worldgen/enigmatica/add_spawn.js#L39

KuryKat commented 1 year ago

@MuteTiefling like @Dariensg said, we assumed that the issue with them spawning too much was the fact that the BYG nether biomes weren't tagged with the vanilla minecraft is_nether, so it caused them to spawn infinitely, so we added the datapack that I provided on the post to try to partially reduce that issue, but I'm not entirely sure it has fixed completely

KuryKat commented 1 year ago

Some tests run by the players seems to show that they are spawning less frequently, when they first used /kill @e[type=cnb:sporeling] to clear them all to see how they'd spawn it had around 115 or more of them, the second time (after reloading with the edited datapack) after waiting for a few minutes returned that it killed 30 of them, then after 20 or so minutes the next one killed 25 of them, so it might have mitigated the issue, needs further testing to be honest, in my opinion, to make sure that the overspawn doesn't happen again

MuteTiefling commented 1 year ago

Ah, that's what I get for reading quick. Alright, I'll get the biomes tagged here and then look into what I can do about the apotheosis minibosses. Might need Shadows' help there.

KuryKat commented 1 year ago

Just as an additional information, for data purposes, these are spark profiles.

With these you can tell that the CNB resource usage went from 16% of the Server Thread to 2% of the Server Thread after the correct tags being applied!

From BEFORE the extra datapack addition:

image

image

From AFTER the extra datapack addition:

image

Shadows-of-Fire commented 1 year ago

Alright, couple things here:

Apotheosis 6.3.0 will be including a finalize field on the minibosses which will allow the SpecialSpawn event to propagate, resulting in Mob#finalizeSpawn still being called.

However, a better solution would be to either split these different mob types into their own entity types (as was done with Skeletons, Wither Skeletons, and Strays in vanilla), or at least delay the type selection to first entity tick instead of in a cancelable method (since it appears that setting the type is critical, and should not rely on such mechanisms).

Another thing of note is that, because Mob#finalizeSpawn would be called before the miniboss is applied (with my new flag set to true), that the type would still be lost if the miniboss were to perform raw nbt application.

This is because raw NBT application uses Entity#readAdditionalSaveData, which normally does not update information if a specific key is absent from the tag. However, your implementation does not check CompoundTag#contains before applying.

Dariensg commented 1 year ago

Thanks for the feedback! I admittedly wrote this code a couple years ago now while I was still learning. I'll try to jump back into it in the next week or so and probably end up splitting the hostile and passive variants into two separate entities.

I'll consider moving the variant logic to first tick, though if the hostile and passive variants are separate entities, it's less crucial, since failure to set a variant wouldn't result in infinite spawning. I will say, however, that in my opinion if someone is to cancel finalizeSpawn, they have to live with the consequences of what they've canceled. I'd say the same if someone was using a Redirect or Overwrite mixin that was breaking something.

I'll also update my NBT reading classes to check for contained data as well, which is totally my bad and my inexperience at that point in time!