tModLoader Subworld Library

John Snail

Terrarian
icon.png

Subworld Library
Dimensions, made easy.
Workshop
Wiki
A tool for modders to easily add dimensions (referred to as subworlds) to their mods, making all the necessary code injections, handling Multiplayer and managing every subworld.

HOW IT WORKS
Subworld Library does a LOT of code injection, as Terraria was not made with subworlds in mind.​
Subworlds are highly customisable; from how big or small they are, to what ModSystems can update inside of them and even how they are lit.​
Subworld Library removes Space, both Oceans and the Underworld from subworlds, allowing them to be extremely small without issues.​

LOADING
Loading a subworld is straightforward. Loading screens can be as simple as text on a plain background, or something complex, like an item selection menu.​

SAVING
Subworlds save to a directory named after the main world. A subworld and/or changes to players inside it can be temporary. Deleting a world deletes all of its subworlds as well.​

MULTIPLAYER
Subworld Library works in Multiplayer with little to no extra work required from modders. A server is opened for every subworld being occupied.​
 
Last edited:
how does your mod exactly work. When I try to make the world with the on mod on it doesn't work it's soft locks the game.
 
I just registered to this forum to post this: if what you have made is what I think it is, and the modding community is as alive as I hope it is, you might have just opened a door to so many possibilities. Alternate dimensions mods and other gimmicks, this is amazing. Now I do have to ask a question, how would this interact with Large World Expander? As the only two ways I could imagine pulling this off is having off screen terrain, or separate hidden world files, either of those I could imagine might interact weirdly with super large worlds.
 
where is the link for the mod
where is the link that takes us to download the mod

Really, double post. @lazermaster351
Also, request for option to change color of the sky when you enter the subworld. @John Snail
Other requests:
Being able to enable bool toggles while the player is in the subworld. (Also vice versa, for a bool to enable while the player isn't in the subworld)
Being able to create custom sun and moon sprites for your subworld (If you can, cloud sprites)
Being able to set the base blocks for your subworld (e.g. dirt is replaced with stone or Clorophyte is replaced by <Modtilenamehere>)
Enable / disable clouds
Enable mod day / night music. (If true, then the music must be defined)
Set which enemies spawn in your subworld (Also if you could, set whether vanilla enemies could spawn e.g. zombies won't spawn if false)
Set whether vanilla ores spawn in the subworld (If set to false, copper, tin, iron, etc. won't generate in the subworld)
Enable / disable cavern layer

This mod has a lot of potential, don't waste it.
 
Last edited:
Really, double post. @lazermaster351
Also, request for option to change color of the sky when you enter the subworld. @John Snail
Other requests:
Being able to enable bool toggles while the player is in the subworld. (Also vice versa, for a bool to enable while the player isn't in the subworld)
Being able to create custom sun and moon sprites for your subworld (If you can, cloud sprites)
Being able to set the base blocks for your subworld (e.g. dirt is replaced with stone or Clorophyte is replaced by <Modtilenamehere>)
Enable / disable clouds
Enable mod day / night music. (If true, then the music must be defined)
Set which enemies spawn in your subworld (Also if you could, set whether vanilla enemies could spawn e.g. zombies won't spawn if false)
Set whether vanilla ores spawn in the subworld (If set to false, copper, tin, iron, etc. won't generate in the subworld)
Enable / disable cavern layer

This mod has a lot of potential, don't waste it.
You can do literally all of these things, even without Subworld Library lol
 
How does one change the sprite of the sun and moon.
Or change dirt on generation, I don't know how to do so.
Or disable clouds.
 
I just registered to this forum to post this: if what you have made is what I think it is, and the modding community is as alive as I hope it is, you might have just opened a door to so many possibilities. Alternate dimensions mods and other gimmicks, this is amazing. Now I do have to ask a question, how would this interact with Large World Expander? As the only two ways I could imagine pulling this off is having off screen terrain, or separate hidden world files, either of those I could imagine might interact weirdly with super large worlds.
Sorry for the super late reply! I checked out how Large World Enabler works, and it looks like it would work with subworlds too.
 
Sorry for the super late reply! I checked out how Large World Enabler works, and it looks like it would work with subworlds too.
No worries, that's great to hear that it might work with it. This has started to pick up, I am interested in seeing where this will go.
 
Oh, this has a forum page lol

This thing, is a :red:ing GODSEND for modders, it's simple and clean and gets the job done! The only thing I real ask for is some better documention and examples, like how to properly override and use a UserInterface class as I'm at a loss on that. Otherwise, love it!

I've been trying to avoid using more dependancies in SGAmod, but I can't pass up on this, not now that demensions in Terraria are so easily accessible to any coder and you don't have to be
Linx145 to do it
 
Oh, this has a forum page lol

This thing, is a :red:ing GODSEND for modders, it's simple and clean and gets the job done! The only thing I real ask for is some better documention and examples, like how to properly override and use a UserInterface class as I'm at a loss on that. Otherwise, love it!

I've been trying to avoid using more dependancies in SGAmod, but I can't pass up on this, not now that demensions in Terraria are so easily accessible to any coder and you don't have to be
Linx145 to do it
Misc.
Subworld Library gets rid of Space, the Underworld, and both Oceans inside subworlds, freeing up tons of world space, and allowing for very small subworlds.​


If you need help with making a subworld, or encounter a bug, please go to the #sublib_help and #sublib_bugs channels in the GaMeterraria Discord respectively.
Well... not completely, the Underworld/heat distortion effect is still present

Also PS to anyone who is going to change Main.spawnTileX and Main.spawnTileY, make SURE the block under this is solid, else your game may softlock during generation!
Learned this the hardway

How does one change the sprite of the sun and moon.
Or change dirt on generation, I don't know how to do so.
Or disable clouds.
This thing lets you generate a clean-slate of a world, the world is completely blank and it's to you to fill it up with things
getting rid of clouds requires you to make a CustomSky and have it activate in the Subworld
I havn't messed with Moon/Sun sprites but I think there's a main. field for it, I know other mods change it via skies
 
Ok so, I uncovered another problem
While instances of mod worlds still exist, it would seem for some reason ModWorlds are not loading any saved modded data
like if you go into a subworld, and check bosschecklist, no bosses are defeated because the downed fields are in their starting values
PS: Exiting a subworld fixes this, but still, I can't use any field values normally, I'm sure I could just reload the modworlds but shouldn't SLLib do that for you?
 
...The only thing I real ask for is some better documention and examples, like how to properly override and use a UserInterface class as I'm at a loss on that. Otherwise, love it!
Yeah, I'm working on better documentation and examples. Thanks!
Well... not completely, the Underworld/heat distortion effect is still present
Ah damn, I completely forgot about that. I'll fix that in 1.1, along with the lighting effect.
Also PS to anyone who is going to change Main.spawnTileX and Main.spawnTileY, make SURE the block under this is solid, else your game may softlock during generation!
That's odd, the game should just spawn you in the air. It may be something else freezing worldgen.
Ok so, I uncovered another problem
While instances of mod worlds still exist, it would seem for some reason ModWorlds are not loading any saved modded data
like if you go into a subworld, and check bosschecklist, no bosses are defeated because the downed fields are in their starting values
PS: Exiting a subworld fixes this, but still, I can't use any field values normally, I'm sure I could just reload the modworlds but shouldn't SLLib do that for you?
If I understand you correctly, this is intended behaviour. Subworlds are entirely new worlds; everything is reset to prevent weird things from occurring. Cache any information you need before calling EnterSubworld.
 
I really like the idea behind this mod, but I'm having trouble implementing it because of the lack of clear documentation. I agree with @IDGCaptainRussia that it would be really helpful - in my opinion, documentation is always pretty important for a "library" style of mod like this one.

A couple other thoughts:
  • The Discord link appears to be invalid. Could you please update it?
  • Is the source for this mod publicly available? This would go a long way towards helping people understand the correct usage for the mod, even without any more documentation. The Wiki link in the first post links to Github, but that repo contains just the compiled .DLL, not the source code.
  • Do you know of any published and/or open-source mods that use this library? Again, a reference implementation would be great to allow us to see some examples of how it could be used.
 
I really like the idea behind this mod, but I'm having trouble implementing it because of the lack of clear documentation. I agree with @IDGCaptainRussia that it would be really helpful - in my opinion, documentation is always pretty important for a "library" style of mod like this one.

A couple other thoughts:
  • The Discord link appears to be invalid. Could you please update it?
  • Is the source for this mod publicly available? This would go a long way towards helping people understand the correct usage for the mod, even without any more documentation. The Wiki link in the first post links to Github, but that repo contains just the compiled .DLL, not the source code.
  • Do you know of any published and/or open-source mods that use this library? Again, a reference implementation would be great to allow us to see some examples of how it could be used.
A: Join the GaMeTerraria Discord Server!
b: I don't think it is, you could snoop around freely with an editor or IlSpy or DnSpy, but it won't help alot as this library is comprised of alot, and I mean... ALOT of IL Editing (which in this decompiled perspective is very hard to read let alone understand).
c: No, pretty sure GaMeTerraria is closed source, and any other mod that is using it hasn't actually, uh used it (Mod of Redemption in this case, which is also closed source so rip you), my mine is open source but I haven't finished the update that adds in Subworlds yet, so you can take a look at that when the comes if you still need to. I also know there's a few other mods in the works using it but they are far from release.
 
Back
Top Bottom