tModLoader Subworld Library

Damn, I loved this library. I made this mod create a Tungsten Brick world, and managed to enter and leave It without problems. :D

I'll try seeing if I can play more with this. Thanks John for such an amazing mod.

Edit:. Oh yeah, It will be a good idea to allow modifying the spawns from the subworld, directly from their class.
That way people can even set custom npc spawns inside the world file, instead of specifying if the subworld is active on the GlobalNpc script, before changing the spawns.

Edit2:. And I found a little bug after entering and leaving the world several times, where my character returned to the original world, falling from the upper left part of the world
 
Last edited:
Do you know how I could run vanilla Terraria WorldGen code? I want to duplicate Terraria's cave system generator but for a new subworld.
 
Have you thought about switching the IL for spooled TCP instances to handle seamless client travel?
Seems like a nice mod for 1 or 2 players but for a grander application it'd be more ideal to have map servers (MMO architecture) and persistency is saved per map instance, say you have a server of like 6 people - this number is somewhat possible with friends so switching worlds might be an agreed vote but for some randoms in a public server people may decline the vote somewhat ruining the experience for the other people, so 3/6 can travel to 7778 for example and the rest can stay on 7777, or even more they might even go to like 7780 for a different world.
 
Have you thought about switching the IL for spooled TCP instances to handle seamless client travel?
Seems like a nice mod for 1 or 2 players but for a grander application it'd be more ideal to have map servers (MMO architecture) and persistency is saved per map instance, say you have a server of like 6 people - this number is somewhat possible with friends so switching worlds might be an agreed vote but for some randoms in a public server people may decline the vote somewhat ruining the experience for the other people, so 3/6 can travel to 7778 for example and the rest can stay on 7777, or even more they might even go to like 7780 for a different world.
I think the only reason he hasn't done something like this is because that's way too much effort for what he wanted to create.
SWL exists because of GaMeTerraria, John Snail could have kept it to his mod only but decided to make a library out of it.
It sure isn't perfect and the net code is especially so in that regard, but it's the best we got for the moment (that still didn't keep people like OS from writing their own versions thou).

But unless TML actively implements a network system like that I don't see any mod doing it themselves (or using a system that does work because people would rather not use someone else's work; the community has this underlying hatred towards the idea of making people download dependencies, and yet TML still doesn't force people to download dependencies and they click the wrong button)
Unless people wanna make like Super Terraria World #2 Robotic Boogaloo thou, I don't see that happening from a modder.
Would be rather neat to see a proper multi-server hosted system in Terraria one day. There are skilled people who want to do this, I just don't think John is gonna be the one to do it (alone, that is)
Besides, he's still waging war against his arch nemesis: Lava backgrounds :p
 
Have you thought about switching the IL for spooled TCP instances to handle seamless client travel?
Seems like a nice mod for 1 or 2 players but for a grander application it'd be more ideal to have map servers (MMO architecture) and persistency is saved per map instance, say you have a server of like 6 people - this number is somewhat possible with friends so switching worlds might be an agreed vote but for some randoms in a public server people may decline the vote somewhat ruining the experience for the other people, so 3/6 can travel to 7778 for example and the rest can stay on 7777, or even more they might even go to like 7780 for a different world.
I'm considering per-subworld servers for 1.4, yes. Only if I manage to get it working using just one port, however. I'm guessing multiple ports would interfere with several things, such as firewalls and even Steam Multiplayer itself.
After I overcome that obstacle, there's an even bigger concern: Worlds use a TON of memory. Even small ones eat up around 135 MB. I'm not sure what the usual size for subworlds will end up being, but it'll only determine how quickly the memory usage adds up.
 
Ok I am going to try my best to explain this since several people here have asked and we just get the same answers "go to the wiki" or "join our discord" some people honestly hate discord they dont like the setup since it feels more like a chat room then a Manuel etc (getting into all the reasons for dislike of discord would be detracting from my point though)
the question
How do we actually USE this ? the wiki/front page is VERY GOOD at getting us interested it tells us what it DOES but not how we USE this umm Program ? Mod ? Library ? is this a Modder tool ? honestly from what I have read this looks more like a tool for molders meaning moders would get this but it would not be all that accessible to average non coding non modding types who saw this cool thing and wanna try it, and I think that might be where the confusion comes from its either a loss in translation or really bad instructions and that's why people keep asking for instructions.

to quote the Wiki
Creating a Subworld

"Classes that derive from Subworld are automatically registered as subworlds. Display names are set with the following localization key: SubworldName.<subworld class name>

Below is a list of fields that can be overridden. Fields that are required are marked in bold."

as my wife said when I showed this to her "what is a class ?" she looked at those instructions as if they where hieroglyphics and that is how most PLAYERS who do not design mods will look at it. the next question is ... what UI is this in ? how do we access this UI your wiki is saying NOTHING about where we are when we are doing this is this in the code is it in the game is it in the chat window a player will not understand what program is even being used. the next part gives a field of commands you can use but again nobody even knows how to access the UI meaning they don't know where they are entering this information even.

and this is why people keep asking for instructions the use of this is unclear in the mod downloader it appears as ready to go you add it to your mods list type a command in a world and away you go but then they try and are confused as to why it doesn't work (and then either come here and ask getting directed to the wiki which just describes what it does not how to do it or remove it as they loose interest)

I love this idea and I can see a lot of crazy awesome things from this but it would be helpful to clear things up for people who are either new to modding or just not in the know and if this is a tool for modders ... maybe put that in the description so players know its not something they can use and is meant for those making cool stuff to make further cool stuff. and also remember lots of people dislike discord they see the discord link and get turned off its your choice to use it but its also the other persons choice to refuse to use it

please if you can understand this is not an attack I like your work but this needs to be said cas otherwise this question might keep coming up or people just might ignore this mod and I would hate to see that
Darmond
 
Last edited:
Ok I am going to try my best to explain this since several people here have asked and we just get the same answers "go to the wiki" or "join our discord" some people honestly hate discord they dont like the setup since it feels more like a chat room then a Manuel etc (getting into all the reasons for dislike of discord would be detracting from my point though)
the question
How do we actually USE this ? the wiki/front page is VERY GOOD at getting us interested it tells us what it DOES but not how we USE this umm Program ? Mod ? Library ? is this a Modder tool ? honestly from what I have read this looks more like a tool for molders meaning moders would get this but it would not be all that accessible to average non coding non modding types who saw this cool thing and wanna try it, and I think that might be where the confusion comes from its either a loss in translation or really bad instructions and that's why people keep asking for instructions.

to quote the Wiki
Creating a Subworld

"Classes that derive from Subworld are automatically registered as subworlds. Display names are set with the following localization key: SubworldName.<subworld class name>

Below is a list of fields that can be overridden. Fields that are required are marked in bold."

as my wife said when I showed this to her "what is a class ?" she looked at those instructions as if they where hieroglyphics and that is how most PLAYERS who do not design mods will look at it. the next question is ... what UI is this in ? how do we access this UI your wiki is saying NOTHING about where we are when we are doing this is this in the code is it in the game is it in the chat window a player will not understand what program is even being used. the next part gives a field of commands you can use but again nobody even knows how to access the UI meaning they don't know where they are entering this information even.

and this is why people keep asking for instructions the use of this is unclear in the mod downloader it appears as ready to go you add it to your mods list type a command in a world and away you go but then they try and are confused as to why it doesn't work (and then either come here and ask getting directed to the wiki which just describes what it does not how to do it or remove it as they loose interest)

I love this idea and I can see a lot of crazy awesome things from this but it would be helpful to clear things up for people who are either new to modding or just not in the know and if this is a tool for modders ... maybe put that in the description so players know its not something they can use and is meant for those making cool stuff to make further cool stuff. and also remember lots of people dislike discord they see the discord link and get turned off its your choice to use it but its also the other persons choice to refuse to use it

please if you can understand this is not an attack I like your work but this needs to be said cas otherwise this question might keep coming up or people just might ignore this mod and I would hate to see that
Darmond

I feel as, one of the first people who has properly used Subworlds the way it was intented, to help give some more insight to what "this" is, who it's for, and some basic guide lines on when (yes, I said when) to use it.

Q: What is it?

A: This is a Library, you know all those "Core" mods you were required to download in Minecraft? It's one of those: a mod that stores code that several other mods can use; this is done so the author can easily update the code and share it between their mods without creating alot of Boilerplate Code in the process.
Subworlds however is a public Library intended to add functional (AKA Subworlds in this case) to the game, it was designed to make mutli-worlds as painless as possible for anyone who wishes to do so... More on that in a minute.

Q: Is it for me? Who's it for?

A: This is for mod-makers, it does NOT add any functionality of its own, it's only an API to be used by mod makers to easily add subworld/dimensions to Terraria. If you want a mod that lets you create a customized dimension, your going to have to wait til someone makes a mod to do that using that.

Q: 'When' can I use it?

A: This is often where alot of the complaining happens, this is honestly a pretty big deal. When I first discovered Subworlds, I wanted to be the first to take advantage of its features (after GaMeTerraria of course), it wasn't super clear at first and Snail got in contact with me when I had questions, but ultimately I figured it out and even expanded my subworlds with extra functionality.
Because here's the thing: I knew what I was doing. Alot of people who want to "use" this library, often don't even know the basics required to use it. These basics would include:

Writing a class to child from Subworld (Terraria doesn't do the best job of even explaining C# basics like "classes", as you'd stated above with your confusion)
Understanding Worldgen (There aren't alot of great worldgen examples out there for TML so this makes sense, it kinda clicked for me since I've done this kinda thing before to an extent)
Using Funcs and Delegates (will confuse you to no end if you don't know what your doing!)

Because of all the hype based around this concept being widely possible, it leads up to alot people who have no idea what their doing wanting to suddenly make dimensions, now there are some good ones coming... but that's just it, they're all WIPs with the exception of a few mods (Polarites, SGAmod, Markoth's Challenge I guess counts), so there really isn't "alot" out there you can play with subworlds yet sadly, but as one of those people (SGAmod in this case) I can tell you, it's good, real good, not perfect, a big buggy, but good!

And about discord, yeah well, as I stated in the final part above, you NEED to know a sizable ammount of C# knowledge before you start using Subworlds, when I started using Subworlds it was alot more bare-bones infomation wise, but the even the little infomation available on the wiki (at the time, there's alot more now) I was able to use Snail's Barebones subworld class to make all my dimensions since. So discord isn't really required for this.
It works, it's just often people who who want to use it aren't ready to use it, yet.
 
Last edited:
Thank you IDGCaptainRussia this is actually an excellent explanation of what is here for the regular player (where I think some of the problem was coming from) knowing this is done in C# and is a tool for modders is very helpful as I said before it looks very plug in play when you first access it which I think is what lead to a lot of confusion, now that I know its a tool I might be able to use it myself if I ever get into modding terraria (my wife saw the hieroglyphics not me I wanted to give you guys her opinion since she is just a normal player .... she also hates it when I do anything with C# as it makes her eyes hurt and I get grumpy for days lol). Since this is a tool and still in development I can understand a bit more why discord was used.

I will suggest very strongly that if there is a way to pin your explanation get pinned if not then in the initial post and on mod section of Tmodloader its stated that this is a moder tool and not a plug and play mod that players can utilize it should prove usefull to other players who stumble upon this

Thank you again for helping to clear that up and I look forward to the creations that you guys make with this as it looks like it opens new exciting options for mods and might even be a way to get around some of the content conflicts (like putting some new biomes in sub worlds instead of the main etc)

P.S. been excited for the idea of Subworld/demensions to come back since I encountered them in Nterraria I am glad someone picked up the torch
 
I'm considering per-subworld servers for 1.4, yes. Only if I manage to get it working using just one port, however. I'm guessing multiple ports would interfere with several things, such as firewalls and even Steam Multiplayer itself.
After I overcome that obstacle, there's an even bigger concern: Worlds use a TON of memory. Even small ones eat up around 135 MB. I'm not sure what the usual size for subworlds will end up being, but it'll only determine how quickly the memory usage adds up.

You will need to modify the connection in order to pipe people into the correct worlds; making an array of sorts necessary to say map 1, map 2... then the connection should handle that. However the persistence there isn't going to be confirmed straightaway since you will need to modify the game loop to include extra maps in the update.
The split server/port configuration is better since you just host map 1 on 7777, map 2 on 7778 and theres no modifying of the loop or arrays to load the map because that server is hosted with that map.
Memory of split servers would probably even out better than pushing it all through the main server, as well as their loop being self contained; no glitches because main got stuck on something... I don't think you have to worry about client state as its all saved locally, MMO's usually take up a lot of memory for their persistent state, but you can have them run in step interval updates to make them do less when theres no players; or just drop the thing entirely until the trigger is hit again in the main.

All I know of terraria though is that the code is mad jank, somewhat new to the modding scene, so not entirely sure what your mileage is in extensibility or how far you can go before the engine just denies you.
 
Trying to make a new world, like full fledged world, space, underworld, etc. but i'm not sure how to do it without recreating the entire world gen. essentially vanilla world gen
 
Trying to make a new world, like full fledged world, space, underworld, etc. but i'm not sure how to do it without recreating the entire world gen. essentially vanilla world gen
There's a change in tML 1.4 that'll make this a lot easier. I suggest waiting for that.
 
Ok so, I would like to know:
Are there any mods that use this mod?
If so, can you provide a name or link?
However if it doesn't, how can I use this mod?
 
There's a change in tML 1.4 that'll make this a lot easier. I suggest waiting for that.
That actually doesn't really help, since tmodloader next update for 1.4 could take months, or even years to come.
Trying to make a new world, like full fledged world, space, underworld, etc. but i'm not sure how to do it without recreating the entire world gen. essentially vanilla world gen
You'd probably need to check the modloader source to get the scripts of the world gen of those parts, and then modify It for your subworld.
But you will probably need part of those default world gen scripts to make your world work as intended.
 
Ok so, I would like to know:
Are there any mods that use this mod?
If so, can you provide a name or link?
However if it doesn't, how can I use this mod?
- GaMeTerraria - SGAmod - Markoth Challenge - Polarities

As far as I know, there aren't very many as TML'ers seem to really hate the idea of using any kind of dependencies, even really useful ones like this...
 
- GaMeTerraria - SGAmod - Markoth Challenge - Polarities

As far as I know, there aren't very many as TML'ers seem to really hate the idea of using any kind of dependencies, even really useful ones like this...
That's a factor, though it's moreso that several mods are adding subworlds in future major updates, have subworlds but aren't released, or keeping the addition of subworlds secret.
- Mod of Redemption
- Shadows of Abaddon
- Metroid Mod
- Enigma
- Risk of Slime Rain
- Dissonant Duality
- Definity
- Deposed Radiance
- Extradimensional
- Macrocosm
- Terrorborn
(Pinkymod and Endless Escapade use their own subworld systems, and thus do not count as using Subworld Library)
 
- GaMeTerraria - SGAmod - Markoth Challenge - Polarities

As far as I know, there aren't very many as TML'ers seem to really hate the idea of using any kind of dependencies, even really useful ones like this...
I was going to make use of Subworlds on my companions mod, to allow the players to visit their world, but I couldn't find a way of making It discrete and not be a dependable content, so I'll have to use another way to do that...

Beside I also read from other modders that this mod really likes to make use of ram. I didn't really made worlds that are that big enough to notice that because I were testing the library, but since my mod makes lots of use of textures...
 
That's a factor, though it's moreso that several mods are adding subworlds in future major updates, have subworlds but aren't released, or keeping the addition of subworlds secret.
- Mod of Redemption
- Shadows of Abaddon
- Metroid Mod
- Enigma
- Risk of Slime Rain
- Dissonant Duality
- Definity
- Deposed Radiance
- Extradimensional
- Macrocosm
- Terrorborn
(Pinkymod and Endless Escapade use their own subworld systems, and thus do not count as using Subworld Library)
Yeah I guess I forgot that part, but when people ask, they're usually asking "what can I play rn that uses this?" as they've likely only seen it mentioned on WIP mods; why I didn't bring that up
I was going to make use of Subworlds on my companions mod, to allow the players to visit their world, but I couldn't find a way of making It discrete and not be a dependable content, so I'll have to use another way to do that...

Beside I also read from other modders that this mod really likes to make use of ram. I didn't really made worlds that are that big enough to notice that because I were testing the library, but since my mod makes lots of use of textures...
Again, what is the problem with dependable content? Your already depending on TModLoader as a modding API...
 
Yeah I guess I forgot that part, but when people ask, they're usually asking "what can I play rn that uses this?" as they've likely only seen it mentioned on WIP mods; why I didn't bring that up

Again, what is the problem with dependable content? Your already depending on TModLoader as a modding API...
I can't really suddenly make people be forced to install subworld library when I'm still developing the content that uses It.

Also, I was aiming at making the content that uses subworld library optional, so one isn't forced to install the library just to be able to play the mod, and only be able to access the subworld using part if has the library installed.
 
I can't really suddenly make people be forced to install subworld library when I'm still developing the content that uses It.

Also, I was aiming at making the content that uses subworld library optional, so one isn't forced to install the library just to be able to play the mod, and only be able to access the subworld using part if has the library installed.
Subworld Library allows you to do that!
 
I was gonna use subworlds but going to be waiting for the aforementioned change in 1.4 if it could happen
 
Back
Top Bottom