addDicTypes causes NPE during INIT stage
LeLobster opened this issue ยท 12 comments
Forge: 14.23.1.2559
BiomeTweakerCore-1.12.2-1.0.22
BiomeTweaker-1.12.2-3.1.323
from Jenkins
Dictionary Types and BiomeManager Entries are left out. Everything else seems to inherit properly.
This is also be related to 'custom' biomes not generating.
I've been testing with Tweaker.createBiome("ominous_woods", "minecraft:forest")
and Tweaker.createBiome("ominous_woods")
during the BIOME_REGISTRY
stage but I can't get it to generate unless I manually fill in the blanks left by inheritProperties
Tweaker.setScriptStage("INIT")
OminousWoods.addToGeneration("WARM", 1000)
OminousWoods.addToGeneration("COOL", 1000)
Tweaker.setScriptStage("POST_INIT")
OminousWoods.addDicTypes("FOREST")
Also two unrelated question to this issue: Is it possible to get a list of commands which are appropriate for which stage?
Right now I'm not sure if a command is just not supported in a stage or if it's a bug.
For example; using addDicTypes
during INIT
gives a NullPointerException
while POST_INIT
is fine. (But then Forge complains about "No types have been added to Biome" and adds their own guess to the type before POST_INIT
occurs )
And is it necessary to define OminousWoods = forBiomes("biometweaker:ominous_woods")
during every new stage?
Or can I declare it during BIOME_REGISTRY
and it will still be available during INIT
Running your script myself, it seems like the create command is copying dictionary types just fine. The woodlands biome only has the "PLAINS" type in my setup, and that was copied over to ominous woods. BiomeManager entries are intentionally not copied. I don't feel copying a biome's "properties" mean its generation weights as well.
I also had no problems running the script at "INIT" or "BIOME_REGISTRY". You're going to have to provide some error logs, since I can't reproduce them.
You only need to define object declarations once. You can actually have OminousWoods = forBiomes("biometweaker:ominous_woods")
at the beginning of your script, before you even create it; as long as it is created before you attempt to modify or use it.
the create command is copying dictionary types just fine.
Yeah, I just tested again and on first try it seemed like it indeed does. Then I don't know went wrong earlier because "Dictionary Types"
was definitely an empty list in the Ominous_Woods (biometweaker_ominous_woods).json
file.
BiomeManager entries are intentionally not copied.
In that case it was most likely also the reason for the biome not generating. Not sure if Dict Types and
BM entries are both needed but at least I got it working now and roughly know why it didn't earlier.
no problems running the script at "INIT"
Tweaker.setScriptStage("INIT")
OminousWoods.addDicTypes("FOREST")
OminousWoods.addToGeneration("WARM", 1000)
OminousWoods.addToGeneration("COOL", 1000)
[23:00:18] [main/INFO] [SuperScript]: Found 3 tweaks to apply for stage INIT. Applying...
[23:00:18] [main/ERROR] [SuperScript]: Failed to execute script command: me.superckl.biometweaker.script.command.generation.ScriptCommandAddDictionaryTypes@16724acf
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: java.lang.NullPointerException
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at me.superckl.biometweaker.util.BiomeHelper.modifyBiomeDicType(BiomeHelper.java:194)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at me.superckl.biometweaker.script.command.generation.ScriptCommandAddDictionaryTypes.perform(ScriptCommandAddDictionaryTypes.java:35)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at me.superckl.api.superscript.script.command.BasicScriptCommandManager.applyCommandsFor(BasicScriptCommandManager.java:50)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at me.superckl.biometweaker.BiomeTweaker.onInit(BiomeTweaker.java:193)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at java.lang.reflect.Method.invoke(Method.java:498)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:606)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at java.lang.reflect.Method.invoke(Method.java:498)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.EventBus.post(EventBus.java:217)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:253)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:231)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at java.lang.reflect.Method.invoke(Method.java:498)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at com.google.common.eventbus.EventBus.post(EventBus.java:217)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:148)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:719)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:352)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:534)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:377)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraft.client.main.Main.main(SourceFile:123)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at java.lang.reflect.Method.invoke(Method.java:498)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
[23:00:18] [main/INFO] [STDERR]: [me.superckl.api.superscript.script.command.BasicScriptCommandManager:applyCommandsFor:53]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
And another example of commands not working during certain stages or maybe it's a bug:
Tweaker.setScriptStage("POST_INIT")
Tweaker.setPlacementStage("POST_ORES")
newTrees = newTreeDecoration()
newTrees.setCount(20)
newTrees.setBlock("traverse:fir_log")
newTrees.setLeafBlock("traverse:fir_leaves")
OminousWoods.addDecoration(newTrees)
results in
[23:10:01] [main/ERROR] [SuperScript]: Failed to find meaning in command setCount(20). It will be ignored.
[23:10:01] [main/ERROR] [SuperScript]: Failed to find meaning in command setBlock("traverse:fir_log"). It will be ignored.
[23:10:01] [main/ERROR] [SuperScript]: Failed to find meaning in command setLeafBlock("traverse:fir_leaves"). It will be ignored.
edit: Small note on the above: This happens during script parsing (before BIOME_REGISTRY
)
Hence my question about what commands to use when. Right now I don't know if I'm just doing it wrong or if there is a bug in the code.
Only BiomeManager types are needed for a biome to generate. The BiomeDicitonary is simply a bookkeeping tool.
The NPE should be fixed in the latest update. The error occurs when adding dictionary types to biomes with no dictionary types. The different script stages resulted in the biome already having dictionary types from the best guessing.
For the decorations, the syntax changed in build 321. It now uses the standard set command syntax for the commands that used to be setXXX()
. They are now, for example
newTrees.set("count", 20)
newTrees.set("mainBlock", "traverse:fir_log")
newTrees.set("leafBlock", "traverse:fir_leaves")
The bleeding edge builds often have undocumented changes. I intend to update the decoration documentation when I upload the next version to CurseForge.
I'm going to close this issue since the main bug has been resolved, but please feel free to keep commenting.
Only BiomeManager types are needed
That is good to know.
The different script stages resulted in the biome already having dictionary types from the best guessing.
This is probably correct, during INIT
Forge detects missing types and adds their own based on a best guess. So during POST_INIT
the dict isn't empty anymore.
I just started experimenting with decorations and the thing I'm mostly questioning right now is what decoration to add during which placementStage
, and during what scriptStage
In general the current documentation is very helpful, and with some messing around it's definitely doable to figure out most options, but there are topics which are really confusing (for me atleast). Mainly scriptStages
.
Also something small I noticed about .set("name", xxx)
:
I would expect it to work like: Plains.set("name", "Custom Plains Name")
but this results in a name with escaped "
's. Something like: \\\"Custom Plains Name\\\"
The way to set a name is Plains.set("name", Custom Plains Name)
and I don't know if this is intentional or a small oversight.
Script stages are mainly meant as a compatibility tool so you can choose when your scripts are executed. There are only a few cases were this is required, such as creating biomes during the "BIOME_REGISTRY" stage. Another example is that you must modify feature counts through "xxxPerChunk" before "POST_INIT". Most commands can be done at any stage.
The placement stages give you flexibility over when your decorations and replacements are done. If you are, for example, creating stone trees, you'll want to do it during or after "POST_ORES", otherwise you'll get ores in your trees. If you, for example, want to replace the top layer of grass in most biomes, that must be done after "BIOME_BLOCKS", since that's when that is placed.
Those escaped quotations are a result of a recent update. Should be fixed now.
Thank you, that clears up a lot, I think I was mostly confused by them because of this issue causing me to think certain functions could only execute during certain scriptStages.
If you, for example, want to replace
So is it actually replacing blocks in the world? I assumed that it would insert your configured blocks into something from Forge which would 'replace' it in the code and not during the actual generation.
Block replacements are actually being replaced in the world, yes. They are not done through any registry in Forge.
That's not what I expected, now I understand why the lag warning is there in the wiki on this topic.
Also is this correct explanation for the decorate stages?
BIOME_BLOCKS
= Top Blocks, Filler Blocks and anything below
POPULATE
= Ores and Caves etc (and including anything from DECORATE
)
DECORATE
= Grass, Flowers, Trees etc.
Now that I have more understanding of how this awesome mod works I'll be experimenting a little bit more tomorrow. If you want I can contribute my script when it's done. I'll cover most aspects of the mod and am currently commenting on anything so that whoever reads it knows exactly whats happening. (including me in the future)
Which also reminds me, I read in the BiomeTweaker.cfg
:
An example script file is created along with this configuration file.
this is no longer the case.
You've pretty much got the stages down. Also of note is that most structures such as villages and strongholds generate during "POPULATE".
I would be ecstatic if you could contribute a detailed script with comments. The reason that example script isn't included anymore is that it was severely out of date. I haven't gotten around to creating another one.
In that case I'll share my work when I'm done, not sure when that is but I'll experiment a bit more with the functions I haven't tested yet tomorrow and after that I'll work on making a serious configuration which I plan on using in my personal modpack.
Should I do a pull request on the wiki when I'm done or just make a gist of the cfg and share the link with you?
Also if I notice any more bugs/errors I'll create a new issue. I think I already noticed another one but I'll confirm tomorrow.