-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added temporary Railways TFC compat (#2)
* Added temporary Railways TFC compat - Locked dependency to this exact railways version - Cursed Enum Mixin (by gigahertz) * Fixed stuff - added Railway Team maven - using Create "all" version from their maven - add @mutable to shadowed value
- Loading branch information
1 parent
7f15648
commit a045388
Showing
7 changed files
with
116 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/allthemods/gravitas2/core/mixin/RailwaysModEnumMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
$VALUES = Arrays.copyOf($VALUES, $VALUES.length + 1); | ||
$VALUES[$VALUES.length-1] = entry; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/allthemods/gravitas2/core/mixin/RailwaysModSetupMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/allthemods/gravitas2/registry/TFCTrackCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
8
src/main/java/com/allthemods/gravitas2/util/GregitasUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters