BiomeTweaker

BiomeTweaker

13M Downloads

[1.18.2] Feature request - addSpawn with weight

jamesjimmy88 opened this issue ยท 10 comments

commented

First of all, thank you for updating this mod to 1.18.2. Datapacks are okay to use as long as the worldgen is vanilla, but modded biomes are either a nightmare to tweak or basically untouchable. This makes everything easy peasy, so thank you.

I would like to request the addition of an optional parameter for the addSpawn command that specifies the spawn weight for the entity.
If it's easier to do, just going with a different command (addSpawnwithWeight ?) is fine

Thanks again

commented

I have also fixed the documentation of the addSpawn command.

commented

You can effectively weight entries by lowering or raising their spawn cost. There is no actual weighting system anymore, but this is roughly equivalent. A lower cost entity will spawn more frequently.

commented

Does this mean that the weight values in the default vanilla datapack are useless then? Good to know, thanks.

commented

I think the weight is actually a parameter?

public ScriptCommandAddSpawn(final BiomePackage pack, final String stage, final ResourceLocation rLoc, final int weight, final int minCount, final int maxCount) throws ClassNotFoundException {

I tried doing

soulSandValley.addSpawn("MONSTER", "minecraft:wither_skeleton", 1, 5)
soulSandValley.setSpawnCost("minecraft:wither_skeleton", 0.15, 0.75)

But I get an arror in the chat:
Failed to parse arguments for command addSpawn("MONSTER", "minecraft:wither_skeleton", 1, 5) @ ScriptContext[scriptName=main.cfg, lineNumber=2]. Reason: No constructors found with matching arguments.

I tried adding an extra numeric parameter and it doesn't throw any error (it still doesn't add any mob, but but at least it compiles)

commented

Ah, yes, this is my mistake in generating the docs. There is a weight parameter that is the first numeric argument of three at the end. You can verify that the spawn is being added by regenerating the output files.

commented

I can't find anything in the output scripts. I assume there should be something in either .minecraft\config\biometweaker\output\entity\minecraft_wither_skeleton.json or .minecraft\config\biometweaker\output\biome\minecraft_soul_sand_valley.json, but there's no mention of spawns in the biome file and there's no biome list in the entity's file. Still, the script is working as intended (it's easy to check since it replaces mobs in a biome), I'll just leave it here for anybody that eventually stumbles upon this issue :

soulSandValley = forBiomes("minecraft:soul_sand_valley")
soulSandValley.removeSpawn("MONSTER", "minecraft:skeleton")
soulSandValley.addSpawn("MONSTER", "minecraft:wither_skeleton", 5000, 1, 5)
soulSandValley.setSpawnCost("minecraft:wither_skeleton", 0.15, 0.75)

Just a small side note: I was being dumb and I did forBiomes("minecraft_soul_sand_valley") instead of forBiomes("minecraft:soul_sand_valley") (I mistakenly copied the name of the output file), but I didn't get any error. The lack of error messages might be intended, but I thought it was worth mentioning.

commented

That should cause an error to be printed in the log, it won't crash the game. Not seeing spawns in the biome output is also a bug that you should look into in the log.

commented

I made a new instance just to test this. This is the test script I used:

soulSandValley = forBiomes("minecraft_soul_sand_valley")
soulSandValley.removeSpawn("MONSTER", "minecraft:skeleton")
soulSandValley.addSpawn("MONSTER", "minecraft:wither_skeleton", 5000, 1, 5)
soulSandValley.setSpawnCost("minecraft:wither_skeleton", 0.15, 0.75)

And here is the log
https://pastebin.com/JFE0F3z9
I don't see anything in there, and there is obviously nothing in the output files since the biome name in the script is wrong

commented

I restarted the instance after correcting the script and I regenerated the output files. Everything is working fine, but I still don't see anything in them.
minecraft_soul_sand_valley.json: https://pastebin.com/HJ305xTD
minecraft_wither_skeleton.json and minecraft_skeleton.json: https://pastebin.com/x6XuE0qY

commented

So what's happening here is a few things:

  • The lack of error is because I now store resource locations internally and there is no check that the resource location actually corresponds to a biome. At some point after the initial registry setup, a check should be run to verify all the resource locations actually correspond to a biome.
  • Spawn information is not included in output because of holder issues causing me to use the network codec and I forgot to manually serialize the spawn info. I'll have to add that back in.