Skip to content

Commit

Permalink
Ready for build
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Jul 27, 2024
1 parent 863aa7d commit 0a03330
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
9 changes: 7 additions & 2 deletions buildSrc/src/main/java/org/mtr/mod/BuildTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.jonafanho.apitools.ModLoader;
import com.jonafanho.apitools.ModProvider;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.gradle.api.Project;

import java.net.URL;
Expand Down Expand Up @@ -63,6 +61,13 @@ public String getModMenuVersion() {
return modMenuVersion;
}

public String getFiltersAPIVersion() {
final String modIdString = "filters-api";
String modMenuVersion = "1.0.0+" + minecraftVersion;
System.out.println("Filters API version: " + modMenuVersion);
return modMenuVersion;
}

public String getForgeVersion() {
String forgeVersion = getJson("https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json").getAsJsonObject().getAsJsonObject("promos").get(minecraftVersion + "-latest").getAsString();
System.out.println("Forge version: " + forgeVersion);
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${buildTools.getFabricApiVersion()}"
//modImplementation(files("E:\\Tianjin-Metro\\libs\\MTR-fabric-4.0.0-beta-8+1.16.5-server.jar"))
modApi "com.terraformersmc:modmenu:${buildTools.getModMenuVersion()}"
modApi("ziyue.filters:filters-fabric:1.0.0+${minecraft_version}") {
modApi("ziyue.filters:filters-fabric:${buildTools.getFiltersAPIVersion()}") {
exclude(group: "net.fabricmc")
}
// Uncomment this if you got "java.lang.IllegalStateException: duplicate fabric loader classes found on classpath".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@

public class ConfigClient
{
public static final Property<Boolean> ENABLE_MTR_FILTERS = new Property<Boolean>("enable_mtr_filters", false)
public static final Property<Boolean> ENABLE_MTR_FILTERS = new Property<>("enable_mtr_filters", false)
{
@Override
public void set(Boolean value) {
value = false; //todo remove this
FilterBuilder.filtersVisibility(CreativeModeTabs.CORE, value);
FilterBuilder.filtersVisibility(CreativeModeTabs.ESCALATORS_LIFTS, value);
FilterBuilder.filtersVisibility(CreativeModeTabs.RAILWAY_FACILITIES, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import ziyue.tjmetro.mod.BlockList;
import ziyue.tjmetro.mod.block.BlockRailwaySignTianjinBMT;
import ziyue.tjmetro.mod.block.BlockStationNamePlate;

Expand Down
3 changes: 1 addition & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"fabric": "*",
"minecraft": "*",
"filters": ">=1.0.0",
"mtr": "*",
"java": ">=16"
"mtr": "*"
}
}
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${buildTools.getForgeVersion()}"
annotationProcessor "org.spongepowered:mixin:+:processor"
implementation fg.deobf("org.mtr:MTR-forge:${mtr_version}+${minecraft_version}-server")
implementation(fg.deobf("ziyue.filters:filters-forge:1.0.0+${minecraft_version}"))
implementation(fg.deobf("ziyue.filters:filters-forge:${buildTools.getFiltersAPIVersion()}"))
annotationProcessor 'systems.manifold:manifold-preprocessor:+'
}

Expand Down
11 changes: 5 additions & 6 deletions forge/src/main/java/ziyue/tjmetro/forge/MainForge.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package ziyue.tjmetro.forge;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import org.mtr.mapping.holder.Screen;
import ziyue.tjmetro.mod.Reference;
import ziyue.tjmetro.mod.Registry;
import ziyue.tjmetro.mod.TianjinMetro;
import ziyue.tjmetro.mod.TianjinMetroClient;
import ziyue.tjmetro.mod.config.ConfigClient;
import ziyue.tjmetro.mod.screen.ConfigClientScreen;

@Mod(Reference.MOD_ID)
public final class MainForge
Expand All @@ -25,13 +21,16 @@ public MainForge() {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> TianjinMetroClient::init);
MinecraftForge.EVENT_BUS.register(this);

#if MC_VERSION <= "11605"
ModLoadingContext.get().registerExtensionPoint(net.minecraftforge.fml.ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> new ConfigClientScreen(new Screen(parent)));
#elif MC_VERSION <= "11905"
#endif
}

// As you see, this is a very dumb thing due to we are using Forge.
// Please read Fabric codes so that you will know how Fabric is awesome.
@SubscribeEvent
public void afterRegistry(GuiScreenEvent.InitGuiEvent event) {
public void afterRegistry(ScreenEvent.Init.Post event) {
//FilterList filterTianjinMetro = FilterList.empty();
//filterTianjinMetro.add(Filters.MISCELLANEOUS);
//filterTianjinMetro.add(Filters.BUILDING);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true
org.gradle.daemon=false

minecraft_version=1.16.5
minecraft_version=1.19.2

# Mod Properties
mod_version=1.0.0-beta-1
Expand Down

0 comments on commit 0a03330

Please sign in to comment.