Making new rails
I don't know if this is the right spot to post this, but I don't know where else.
So, I'm working on an addon that adds a wood type matching that of the Copper Casing, and I want to have it compatible with Steam n Rails. I already have all of the textures made, but I was wondering how I would be able to add the different rails in my mod? I'm still somewhat new to modding and if someone had some sort of guide it would be really appreciated.
Note: This is on Forge 1.20.1
6 Replies
Hello @Encased Fan! Someone will help you shortly, please do not ping moderators or other people and just wait for someone to come help.
you don't need SnR for this, actually. We PR'ed the custom track API into Create, so what you need to do is register a new TrackMaterial, and register a TrackBlock for that material - you can basically just copy the registration for Create's andesite tracks
Where would i do this? Also, would this also add the wide and thin tracks too?
Foreword: You can either depend on SnR, or have an optional dependency for wide/narrow tracks. A hard dependency is easier for you, but potentially annoying for your users.
I'm going to assume that you're already set up with Create and are registering your blocks with Registrate (and therefore have datagen set up). If that isn't the case, you'll have to adapt this a bit:
to start, you'll want a class called something like
MyModTrackMaterials
. You'll want to
Then you can register a track material like so:
The standardModels()
call means it'll use standard track models, with textures at src/main/resources/assets/mymod/textures/block/track/mywood/
The textures you'll need in that directory are:
- standard_track_mywood.png
- standard_track_crossing_mywood.png
- standard_track_mip_mywood.png
- portal_track_mywood.png
- portal_track_mip_mywood.png
Note that the last two can be generated by this script: https://github.com/Layers-of-Railways/MinecraftGraphicsScripts/blob/master/railway/convert.py
Just clone the repo, install the requirements.txt, throw the first three textures in the base_tracks
directory (according to the existing structure), and run the script. Then you'll get the portal textures in the portal_tracks
directory (which will be newly created)
In your track materials class, you should also make an empty static method called register
that you call in your mod constructor
actual block registration in next message (reaching character limit)
As to registering the track block itself:
If you're hard depending on SnR, you can just use the class https://github.com/Layers-of-Railways/Railway/blob/1.19/dev/common/src/main/java/com/railwayteam/railways/content/custom_tracks/CustomTrackBlockStateGenerator.java. Otherwise, you'll have to copy it. Note that I'm intentionally linking the 1.19 version, because the 1.20 version has some multiloader stuff abstracted out, but it should be trivial (or unnecessary to port).
Next, whether you are hard depending on SnR or not, in your block registration class, copy the makeTrack
methods from https://github.com/Layers-of-Railways/Railway/blob/1.20/dev/common/src/main/java/com/railwayteam/railways/registry/CRBlocks.java. There's a few (fairly obvious) places where you'll need to remove or edit SnR-specific bits, particularly changing line 159
to just directly use Create's tag, and changing line 166
to use MyMod.asResource
instead of Railways.asResource
.
Next, if you are NOT hard depending on SnR, you'll need to copy addToBlockEntityType
from https://github.com/Layers-of-Railways/Railway/blob/1.20/dev/common/src/main/java/com/railwayteam/railways/registry/CRTrackMaterials.java, as well as the https://github.com/Layers-of-Railways/Railway/blob/1.19/dev/common/src/main/java/com/railwayteam/railways/mixin/AccessorBlockEntityType.java mixin
Finally, you can simply register your track block like so:
Wide/Narrow track details in next messageI really appreciate your help.
If you are hard depending on SnR, you can do the wide/narrow registration in
MyModBlocks
, otherwise you have to do it in a separate class that you must be careful to only load if SnR is present.
I'd look at https://github.com/Layers-of-Railways/Railway/blob/1.20/dev/common/src/main/java/com/railwayteam/railways/compat/tracks/GenericTrackCompat.java to base that bit off ofGitHub
Railway/common/src/main/java/com/railwayteam/railways/compat/tracks...
Official repository of the Create Railways mod for Minecraft - Layers-of-Railways/Railway