• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

tModLoader Subworld Library

John Snail

Terrarian
icon.png

Subworld Library
Dimensions, made easy.
WikiDirect Mod Browser download linkAlt. download link

Subworld Library allows you to easily add dimensions (referred to as subworlds), handling most of the hard work, including loading, saving, and Multiplayer compatibility.

What it does, in more detail:

Registering
Any class that derives from the Subworld class is automatically registered as a subworld. Subworlds are highly customisable; from their size and how they generate, to whether they or the players inside of them save, to even what ModWorld is allowed to update while inside of them.​

Loading
Loading a subworld is as simple as calling "SLWorld.EnterSubworld". Each subworld can have a custom loading UI if its class overrides "loadingUIState". The UI can even persist after the world is loaded if "loadingUI" is overridden.​

Saving
Subworlds can be set to be either temporary or permanent. Subworlds can also prevent players from saving while inside them. Subworld Library also handles deleting subworlds when their main world is deleted.​

Multiplayer
Subworld Library doesn't just handle loading, saving, etc. in Singleplayer; it also does so in Multiplayer, with little to no extra work required on your end.​

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.
 
Last edited:

Krispyhappy

Eye of Cthulhu
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.
 

Narret

Terrarian
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.
 

EvanKrusher948

Skeletron Prime
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:

John Snail

Terrarian
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
 

EvanKrusher948

Skeletron Prime
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.
 

John Snail

Terrarian
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.
 

Narret

Terrarian
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?
 

John Snail

Terrarian
...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.
 

Articuno

Terrarian
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.
 
Top Bottom