• PC NEWS: 1.4.2.3 update is out! More info here. Report bugs here
  • CONSOLE 1.4 LAUNCHES SEP 30: The official launch date for Journey's End to arrive on Xbox and PlayStation is September 30th! Click here for more info. The plan is to have the update on Switch out later this year. Stay up to date with console news here.
  • MOBILE NEWS: Stay up to date with the latest mobile news here. Report mobile bugs here

tModLoader Subworld Library

Yeah... Subworlds has Weakref support lol, guess I forgot to mention that
John admits the wiki needs a redo so that's likely why you missed it.
Anyways I was under the impression that you weren't making optional content (I should consider that at some point myself, the subworld stuff in SGAmod is already set up to be acquirable in MP outside of the subworlds)
 

Nakano15

Terrarian
I need a little help with call references. I tried creating an object to ease the calls, but something is going wrong, and the subworld is failing to be registered, and I can't find out why.

This is the class I made to try easing subworld creation. nakano15/giantsummon
And the test map.

It keeps showing "World creation failed.", which only happens when registering fails.

Could someone point what I'm doing wrong?
 

SunCrafterHP

Terrarian
Apologies for my lack of understanding, but I can't even begin to grasp what's being said here.
What's a subclass? Where do I find or create a subclass? What does SubworldName.<subworld class name> mean?

I'm not very technical minded so all of this soars way past my understanding, and while I see valiant attempts to document and describe the mod here, I think it needs to be clarified and dumbed down so the less technical minded like us have a chance at using this mod

If someone has the time, making a video covering this and how to set up a Subworld would help tremendously! I'm more of a visual learner so watching someone go step by step would make the process a breeze
 

Tyndareus

Terrarian
Apologies for my lack of understanding, but I can't even begin to grasp what's being said here.
What's a subclass? Where do I find or create a subclass? What does SubworldName.<subworld class name> mean?

I'm not very technical minded so all of this soars way past my understanding, and while I see valiant attempts to document and describe the mod here, I think it needs to be clarified and dumbed down so the less technical minded like us have a chance at using this mod

If someone has the time, making a video covering this and how to set up a Subworld would help tremendously! I'm more of a visual learner so watching someone go step by step would make the process a breeze
Its a derived class inheriting from Subworld. You create one by inheriting from it in normal C# fashion

Then its specified that the localization key is SubworldName.<subworld class name>, so a hell subworld; Hell.HellSubworld, its most likely automatic.
 

SunCrafterHP

Terrarian
Its a derived class inheriting from Subworld. You create one by inheriting from it in normal C# fashion

Then its specified that the localization key is SubworldName.<subworld class name>, so a hell subworld; Hell.HellSubworld, its most likely automatic.
Where do I define or specify or create the Subworlds? In which file or folder?

I think I understand what classes are now if they define the type of subworld or biome the subworld is created with
 

rf_illumination

Terrarian
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 running a medium sized public server and this would be an amazing mod! Being able to run multiple server instances on different ports and switch between them seamlessly in game is a dream. Would allow servers to make use of more of its cores.
 

RenRllySad

Retinazer
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
For the enemy spawns, i've attempted every combination possible to disable the spawn pool and enable a custom, but still can't figure it out. Any pointers?
 

Nakano15

Terrarian
For the enemy spawns, i've attempted every combination possible to disable the spawn pool and enable a custom, but still can't figure it out. Any pointers?
Custom ModWorld comes to mind. Or create some kind of hook on your mod's modworld to change the custom spawns based on whatever the subworld you are.
 
I would suggest how I did it, but mine involves a delegate field that allowed easy random npc customization so... Not a good example.

You need to use EditSpawnPool and set EVERY npc's (loop through all existing npc types, I like to use an array that will be resized to match this count, like Main.NPCTexture.length) spawn chance to 0, then set the NPCs you want to spawn.
 

Nakano15

Terrarian
I would suggest how I did it, but mine involves a delegate field that allowed easy random npc customization so... Not a good example.

You need to use EditSpawnPool and set EVERY npc's (loop through all existing npc types, I like to use an array that will be resized to match this count, like Main.NPCTexture.length) spawn chance to 0, then set the NPCs you want to spawn.
Can't simply clear the list before adding the custom monsters?
 
Can't simply clear the list before adding the custom monsters?
you do, by running a forloop with EVERY npc type. Yeah this part of TML (and Terraria) is pretty gross in how it works if you want to override the entire spawn pool.

It's also home to one of the most hard-coded limitations in the game: when in the sky, ANY enemy can spawn in the air. (I'm sure you've seen plenty of times where modded enemies just fall out of the sky in space; this is why) You have no control over whether a specific enemy enemy should spawn in the air or on the ground.

And I didn't throw in the towel, I wanted to see if I could IL patch this, and let me tell you, this is a great example of Spaghettis Redcode, at its best. I had no idea where to even start with a patch...
 

Nakano15

Terrarian
Or, could use pool.Clear();
I used It on my leveling mod's graveyard biome, It actually works.
clear.png


I actually don't play tModLoader with mods that adds new npcs and stuffs, so I didn't noticed that problem yet of monsters falling from the sky, but the tModLoader devs could have at least added a flag to check if there's ground under the monster. Beside the modders could check themselves if there's floor under the spawn tile (If the spawn tile isn't actually the solid tile).

Beside, I found this variable here on NPCSpawnInfo: "spawnTileType", I have no idea what is It for, though. Maybe It tells if the tile is solid or not?
 
Or, could use pool.Clear();
I used It on my leveling mod's graveyard biome, It actually works.
View attachment 328490

I actually don't play tModLoader with mods that adds new npcs and stuffs, so I didn't noticed that problem yet of monsters falling from the sky, but the tModLoader devs could have at least added a flag to check if there's ground under the monster. Beside the modders could check themselves if there's floor under the spawn tile (If the spawn tile isn't actually the solid tile).

Beside, I found this variable here on NPCSpawnInfo: "spawnTileType", I have no idea what is It for, though. Maybe It tells if the tile is solid or not?
that works.

Don't blame the TML devs, remember they don't work with the source code, they have to "patch it" so they can legally keep the project, and also keep it open source. This NOT going to be an easy patch. it's not something they can just insert into one line to make it work, there are SEVERAL checks for things like if the player is in the sky, if the enemy spawning is say: a harpy, several times on different lines. This is the infamous Redcode at its finest.

"spawnTileType" this is how you control what tile the NPC can spawn on, this is also accessible in ModNPC's spawn method override as well. But again, it doesn't help with the whole "air" thing, that's another level of hardcoded as mentioned above. The only real control you have towards that is checking if the player is in the sky and that's it.

FYI: "Redcode" is TML jargon given to describe alot of the Yandre-sim levels of code in Terraria, written by Red himself when he was... alot worse.
 
I'm sorry but this doesn't really make sense what actually is this mod? How do you use it? Are you saying I can create a world, then while I'm playing I can open up a portal to another world and play inside that one without having to actually create multiple worlds in the menu? I don't understand what you mean by " Loading a subworld is as simple as calling 'SLWorld.EnterSubworld'. ". What do you mean calling? Like calling it like a number? Obviously you can't do that so idk what that's supposed to mean. These two don't make sense to me either: "Each subworld can have a custom loading UI if its class overrides 'loadingUIState'. " . And: "Any class that derives from the Subworld class is automatically registered as a subworld". What do you mean class? Class of what? How can a class meaning a category or type of something override a code? Sorry man idk what's going on it's just really kind of a vague explanation of what the mod is and what you're actually making, and how and where to do it. I'm sure it's a good mod I'm not trying to be ungrateful for this free content here but I just would like to know what it is so I can actually enjoy your mod, thanks.
 

Nakano15

Terrarian
I'm sorry but this doesn't really make sense what actually is this mod? How do you use it? Are you saying I can create a world, then while I'm playing I can open up a portal to another world and play inside that one without having to actually create multiple worlds in the menu? I don't understand what you mean by " Loading a subworld is as simple as calling 'SLWorld.EnterSubworld'. ". What do you mean calling? Like calling it like a number? Obviously you can't do that so idk what that's supposed to mean. These two don't make sense to me either: "Each subworld can have a custom loading UI if its class overrides 'loadingUIState'. " . And: "Any class that derives from the Subworld class is automatically registered as a subworld". What do you mean class? Class of what? How can a class meaning a category or type of something override a code? Sorry man idk what's going on it's just really kind of a vague explanation of what the mod is and what you're actually making, and how and where to do it. I'm sure it's a good mod I'm not trying to be ungrateful for this free content here but I just would like to know what it is so I can actually enjoy your mod, thanks.
Wall of text! Skipping!

Let's see if I can explain this mod to you:
This mod can be used by other modders, so they can add on their mods the possibility of having other worlds inside your game world.
Alone, this mod wont offer you anything, you would need to have mods that makes use of this library to actually play with what It offers.

Did I explained It right?
 

Dan Yami

Duke Fishron
I'm sorry but this doesn't really make sense what actually is this mod? How do you use it? Are you saying I can create a world, then while I'm playing I can open up a portal to another world and play inside that one without having to actually create multiple worlds in the menu? I don't understand what you mean by " Loading a subworld is as simple as calling 'SLWorld.EnterSubworld'. ". What do you mean calling? Like calling it like a number? Obviously you can't do that so idk what that's supposed to mean. These two don't make sense to me either: "Each subworld can have a custom loading UI if its class overrides 'loadingUIState'. " . And: "Any class that derives from the Subworld class is automatically registered as a subworld". What do you mean class? Class of what? How can a class meaning a category or type of something override a code? Sorry man idk what's going on it's just really kind of a vague explanation of what the mod is and what you're actually making, and how and where to do it. I'm sure it's a good mod I'm not trying to be ungrateful for this free content here but I just would like to know what it is so I can actually enjoy your mod, thanks.
It's a lib mod dude, it doesn't do anything on its own. Other mods make use of it to add subworlds. Think of it like the Nether and End in Minecraft, seperate "dimensions" that are part of the same world.

Mod of Redemption, SoA, Polarities and a few other mods will/are using this mod, maybe check them out? (but not SoA it sucks until we fix everything)
 
It's a lib mod dude, it doesn't do anything on its own. Other mods make use of it to add subworlds. Think of it like the Nether and End in Minecraft, seperate "dimensions" that are part of the same world.

Mod of Redemption, SoA, Polarities and a few other mods will/are using this mod, maybe check them out? (but not SoA it sucks until we fix everything)
Honestly surprising how it's still "few are", and mostly mods "will" use it.
But yeah what Dan said, almost every mod (or coming update) that is using Subworlds is still a WIP and hasn't released. the Only mods I know of that are released with functional Subworlds are Polarities, SGAmod, and Markoth's Challenge (a chinese mod).
Probable some other unknown mods out there too, but I hadn't found any others as of now.

Edit: forgot GaMeTerraria, can't forget the mod it was originally made for!
 
Last edited:
Top Bottom