Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added temporary Railways TFC compat #2

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ repositories {
includeGroup "dev.ftb.mods"
}
}
maven {
url "https://maven.ithundxr.dev/releases"
content {
includeGroup "com.railwayteam.railways"
}
}
flatDir {
dir 'libs'
}
}

dependencies {
Expand All @@ -150,6 +159,11 @@ dependencies {
modImplementation("dev.ftb.mods:ftb-library-forge:${project.ftb_library_version}") { transitive = false }
modImplementation("dev.ftb.mods:ftb-teams-forge:${project.ftb_teams_version}") { transitive = false }

modRuntimeOnly("com.jozufozu.flywheel:flywheel-forge-1.20.1:0.6.10-7")
modRuntimeOnly("com.simibubi.create:create-1.20.1:0.5.1.f-26:all") { transitive = false }
modImplementation("blank:Steam_Rails-1.5.3+forge-mc1.20.1") // fixed Accessor
pietro-lopes marked this conversation as resolved.
Show resolved Hide resolved
pietro-lopes marked this conversation as resolved.
Show resolved Hide resolved
// modImplementation("com.railwayteam.railways:Steam_Rails-forge-1.20.1:1.5.3+forge-mc1.20.1") { transitive = false } // Does not work, mixin parse bug

modRuntimeOnly("vazkii.patchouli:Patchouli:${project.minecraft_version}-${project.patchouli_version}-FORGE")
modRuntimeOnly("top.theillusivec4.curios:curios-forge:${project.curios_version}+${project.minecraft_version}")
modRuntimeOnly("dev.toma.configuration:configuration-forge-${project.minecraft_version}:${project.configuration_version}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.allthemods.gravitas2.core.mixin;
import com.allthemods.gravitas2.util.GregitasUtil;
import com.railwayteam.railways.compat.Mods;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.Arrays;

@Mixin(Mods.class)
public class RailwaysModEnumMixin
{
@Shadow(remap = false)
@Final
@Mutable
private static Mods[] $VALUES;

@SuppressWarnings("SameParameterValue")
@Invoker(value="<init>")
private static Mods create(String name, int ordinal, String fabricId)
{
throw new IllegalStateException("Unreachable");
}

static
{
var entry = create("TFC", $VALUES.length, "tfc");

GregitasUtil.RailwaysTFC = entry;

//noinspection ShadowFinalModification
pietro-lopes marked this conversation as resolved.
Show resolved Hide resolved
$VALUES = Arrays.copyOf($VALUES, $VALUES.length + 1);
$VALUES[$VALUES.length-1] = entry;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.allthemods.gravitas2.core.mixin;

import com.allthemods.gravitas2.registry.TFCTrackCompat;
import com.railwayteam.railways.ModSetup;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ModSetup.class)
public class RailwaysModSetupMixin {

@Inject(method = "register()V", at = @At("TAIL"), remap = false)
private static void gregitas$registerTFC(CallbackInfo ci) {
TFCTrackCompat.register();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.allthemods.gravitas2.registry;

import com.allthemods.gravitas2.util.GregitasUtil;
import com.railwayteam.railways.Railways;
import com.railwayteam.railways.compat.tracks.GenericTrackCompat;
import net.minecraft.resources.ResourceLocation;

public class TFCTrackCompat extends GenericTrackCompat {
TFCTrackCompat() {
super("tfc");
}

@Override
protected boolean registerTracksAnyway() {
return super.registerTracksAnyway() || GregitasUtil.RailwaysTFC.isLoaded;
}

@Override
protected ResourceLocation getSlabLocation(String name) {
return asResource("wood/planks/" + name + "_slab");
}

private static boolean registered = false;
public static void register() {
if (registered) {
Railways.LOGGER.error("Duplicate registration of TerraFirmaCraft track compat");
return;
}
registered = true;
Railways.LOGGER.info("Registering tracks for TerraFirmaCraft");
new TFCTrackCompat().register(
"acacia", "ash", "aspen", "birch", "blackwood",
"chestnut", "douglas_fir", "hickory", "kapok", "mangrove",
"maple", "oak", "palm", "pine", "rosewood",
"sequoia", "spruce", "sycamore", "white_cedar", "willow"
);
}
}
8 changes: 2 additions & 6 deletions src/main/java/com/allthemods/gravitas2/util/GregitasUtil.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.allthemods.gravitas2.util;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
import com.gregtechceu.gtceu.api.item.TagPrefixItem;
import net.dries007.tfc.common.capabilities.heat.HeatCapability;
import net.dries007.tfc.common.capabilities.heat.IHeat;
import com.railwayteam.railways.compat.Mods;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.MissingMappingsEvent;

public class GregitasUtil {

public static Mods RailwaysTFC;
public static <T> void remap(MissingMappingsEvent.Mapping<T> mapping) {
ResourceLocation key = mapping.getKey();
T newThing = remapId(key, mapping.getRegistry());
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ license = "LGPLv3" # Want to make your mod open source? Check out https://choose
versionRange = "[3.1.0-beta,)"
ordering = "AFTER"
side = "BOTH"
[[dependencies.gregitas_core]]
modId = "railways"
mandatory = true
versionRange = "1.5.3+forge-mc1.20.1"
ordering = "AFTER"
side = "BOTH"
2 changes: 2 additions & 0 deletions src/main/resources/gregitas_core.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"MixinHelpersMixin",
"PlaceBlockSpecialPacketMixin",
"PlacedItemBlockEntityMixin",
"RailwaysModEnumMixin",
"RailwaysModSetupMixin",
"TagPrefixMixin",
"TagPrefixOreTypeAccessor"
],
Expand Down