Skip to content

Commit

Permalink
Merge pull request Minecraft-Transit-Railway#1004 from Minecraft-Tran…
Browse files Browse the repository at this point in the history
…sit-Railway/resource-pack-creator

Resource Pack Creator
  • Loading branch information
jonafanho authored Nov 18, 2024
2 parents 614dc6d + 903d65e commit 5d407ac
Show file tree
Hide file tree
Showing 163 changed files with 5,260 additions and 468 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ jobs:
distribution: 'zulu'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Setup website files
run: ./gradlew fabric:setupWebsiteFiles
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Node packages
run: npm ci --prefix buildSrc/src/main/resources/website
- name: Build Angular
run: npm run build --prefix buildSrc/src/main/resources/website
- name: Setup Fabric files
run: ./gradlew fabric:setupFiles -PminecraftVersion="${{ matrix.minecraft }}" -PpatreonApiKey="${{ secrets.PATREON_API_KEY }}"
- name: Setup Forge files
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ run/
generated/
loot_tables/
**/org/mtr/mixin/
fabric/logs
forge/src/main/java/org/mtr/core
forge/src/main/java/org/mtr/legacy
forge/src/main/java/org/mtr/mod
forge/src/main/resources/assets
forge/src/main/resources/data
forge/src/main/resources/META-INF
**/website/*.json
**/website/src/app/entity/generated
**/website/src/styles.css
**/website/.gitignore
fabric.mod.json
mtr.accesswidener
Keys.java
Patreon.java
JadeConfig.java
WthitConfig.java
wthit_plugins.json
mtr_custom_resources.json
**/font/mtr.json
**/lang/*.json
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ subprojects {
repositories {
flatDir { dirs "../libs" }
maven { url "https://repo.codemc.org/repository/maven-public" }
maven { url = "https://api.modrinth.com/maven/" }
maven { url = "https://maven4.bai.lol/" }
}

shadowJar {
Expand Down
59 changes: 43 additions & 16 deletions buildSrc/src/main/java/org/mtr/mod/BuildTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.gradle.api.Project;
import org.mtr.mapping.mixin.CreateAccessWidener;
import org.mtr.mapping.mixin.CreateClientWorldRenderingMixin;
import org.mtr.mapping.mixin.CreatePlayerTeleportationStateAccessor;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -57,6 +58,7 @@ public BuildTools(String minecraftVersion, String loader, Project project) throw
final Path mixinPath = path.resolve("src/main/java/org/mtr/mixin");
Files.createDirectories(mixinPath);
CreateClientWorldRenderingMixin.create(minecraftVersion, loader, mixinPath, "org.mtr.mixin");
CreatePlayerTeleportationStateAccessor.create(minecraftVersion, loader, mixinPath, "org.mtr.mixin");
}

public String getFabricVersion() {
Expand All @@ -69,15 +71,37 @@ public String getYarnVersion() {

public String getFabricApiVersion() {
final String modIdString = "fabric-api";
return new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, ModLoader.FABRIC, "").get(0).fileName.split(".jar")[0].replace(modIdString + "-", "");
return new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, ModLoader.FABRIC, "").get(0).fileName.split("\\.jar")[0].replace(modIdString + "-", "");
}

public boolean hasJadeSupport() {
return loader.equals("fabric") ? majorVersion >= 17 : majorVersion >= 19;
}

public String getJadeVersion() {
if (minecraftVersion.equals("1.19.4")) {
return loader.equals("fabric") ? "10.4.0" : "10.1.1"; // 1.19.4 version not working
}
final String modIdString = "jade";
final String[] fileNameSplit = new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, loader.equals("fabric") ? ModLoader.FABRIC : ModLoader.FORGE, "").get(0).fileName.split("-");
return fileNameSplit[fileNameSplit.length - 1].split("\\.jar")[0] + (minecraftVersion.equals("1.20.1") ? "+" + loader : "");
}

public boolean hasWthitSupport() {
return majorVersion >= 17;
}

public String getWthitVersion() {
final String modIdString = "wthit";
return new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, loader.equals("fabric") ? ModLoader.FABRIC : ModLoader.FORGE, "").get(0).fileName.split("\\.jar")[0].replace(modIdString + "-", "");
}

public String getModMenuVersion() {
if (minecraftVersion.equals("1.20.4")) {
return "9.0.0"; // TODO latest version not working
}
final String modIdString = "modmenu";
return new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, ModLoader.FABRIC, "").get(0).fileName.split(".jar")[0].replace(modIdString + "-", "");
return new ModId(modIdString, ModProvider.MODRINTH).getModFiles(minecraftVersion, ModLoader.FABRIC, "").get(0).fileName.split("\\.jar")[0].replace(modIdString + "-", "");
}

public String getForgeVersion() {
Expand Down Expand Up @@ -196,20 +220,23 @@ public void getPatreonList(String key) throws IOException {
stringBuilder.append("private Patreon(String name,String tierTitle,int tierAmount,int tierColor){this.name=name;this.tierTitle=tierTitle;this.tierAmount=tierAmount;this.tierColor=tierColor;}public static Patreon[]PATREON_LIST={\n");

if (!key.isEmpty()) {
final JsonObject jsonObjectData = getJson("https://www.patreon.com/api/oauth2/v2/campaigns/7782318/members?include=currently_entitled_tiers&fields%5Bmember%5D=full_name,lifetime_support_cents,patron_status&fields%5Btier%5D=title,amount_cents&page%5Bcount%5D=" + Integer.MAX_VALUE, "Authorization", "Bearer " + key).getAsJsonObject();
final Object2ObjectAVLTreeMap<String, JsonObject> idMap = new Object2ObjectAVLTreeMap<>();
jsonObjectData.getAsJsonArray("included").forEach(jsonElementData -> {
final JsonObject jsonObject = jsonElementData.getAsJsonObject();
idMap.put(jsonObject.get("id").getAsString(), jsonObject.getAsJsonObject("attributes"));
});

jsonObjectData.getAsJsonArray("data").forEach(jsonElementData -> {
final JsonObject jsonObjectAttributes = jsonElementData.getAsJsonObject().getAsJsonObject("attributes");
final JsonArray jsonObjectTiers = jsonElementData.getAsJsonObject().getAsJsonObject("relationships").getAsJsonObject("currently_entitled_tiers").getAsJsonArray("data");
if (!jsonObjectAttributes.get("patron_status").isJsonNull() && jsonObjectAttributes.get("patron_status").getAsString().equals("active_patron") && !jsonObjectTiers.isEmpty()) {
patreonList.add(new Patreon(jsonObjectAttributes, idMap.get(jsonObjectTiers.get(0).getAsJsonObject().get("id").getAsString())));
}
});
try {
final JsonObject jsonObjectData = getJson("https://www.patreon.com/api/oauth2/v2/campaigns/7782318/members?include=currently_entitled_tiers&fields%5Bmember%5D=full_name,lifetime_support_cents,patron_status&fields%5Btier%5D=title,amount_cents&page%5Bcount%5D=" + Integer.MAX_VALUE, "Authorization", "Bearer " + key).getAsJsonObject();
final Object2ObjectAVLTreeMap<String, JsonObject> idMap = new Object2ObjectAVLTreeMap<>();
jsonObjectData.getAsJsonArray("included").forEach(jsonElementData -> {
final JsonObject jsonObject = jsonElementData.getAsJsonObject();
idMap.put(jsonObject.get("id").getAsString(), jsonObject.getAsJsonObject("attributes"));
});

jsonObjectData.getAsJsonArray("data").forEach(jsonElementData -> {
final JsonObject jsonObjectAttributes = jsonElementData.getAsJsonObject().getAsJsonObject("attributes");
final JsonArray jsonObjectTiers = jsonElementData.getAsJsonObject().getAsJsonObject("relationships").getAsJsonObject("currently_entitled_tiers").getAsJsonArray("data");
if (!jsonObjectAttributes.get("patron_status").isJsonNull() && jsonObjectAttributes.get("patron_status").getAsString().equals("active_patron") && !jsonObjectTiers.isEmpty()) {
patreonList.add(new Patreon(jsonObjectAttributes, idMap.get(jsonObjectTiers.get(0).getAsJsonObject().get("id").getAsString())));
}
});
} catch (Exception ignored) {
}

Collections.sort(patreonList);
}
Expand Down
18 changes: 15 additions & 3 deletions buildSrc/src/main/resources/schema/resource/customResources.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
"javaImplements": [
"SerializedDataBase"
],
"javaConstructorFields": [
"resourceProvider"
],
"properties": {
"vehicles": {
"type": "array",
"items": {
"$ref": "vehicleResource.json"
"$ref": "vehicleResource.json",
"parameters": [
"ResourceProvider"
]
}
},
"signs": {
Expand All @@ -20,13 +26,19 @@
"rails": {
"type": "array",
"items": {
"$ref": "railResource.json"
"$ref": "railResource.json",
"parameters": [
"ResourceProvider"
]
}
},
"objects": {
"type": "array",
"items": {
"$ref": "objectResource.json"
"$ref": "objectResource.json",
"parameters": [
"ResourceProvider"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"javaImplements": [
"SerializedDataBase"
],
"properties": {
"modelResource": {
"type": "string"
},
"modelPropertiesResource": {
"type": "string"
},
"positionDefinitionsResource": {
"type": "string"
}
},
"required": [
"modelResource",
"modelPropertiesResource",
"positionDefinitionsResource"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
}
},
"condition": {
"$ref": "PartCondition"
"$ref": "PartCondition",
"typeScriptEnum": "NORMAL|AT_DEPOT|ON_ROUTE_FORWARDS|ON_ROUTE_BACKWARDS|DOORS_CLOSED|DOORS_OPENED|CHRISTMAS_LIGHT_RED|CHRISTMAS_LIGHT_YELLOW|CHRISTMAS_LIGHT_GREEN|CHRISTMAS_LIGHT_BLUE"
},
"renderStage": {
"$ref": "RenderStage"
"$ref": "RenderStage",
"typeScriptEnum": "LIGHT|ALWAYS_ON_LIGHT|INTERIOR|INTERIOR_TRANSLUCENT|EXTERIOR"
},
"type": {
"$ref": "PartType"
"$ref": "PartType",
"typeScriptEnum": "NORMAL|DISPLAY|FLOOR|DOORWAY|SEAT"
},
"displayXPadding": {
"type": "number",
Expand Down Expand Up @@ -59,7 +62,8 @@
"minimum": 0
},
"displayType": {
"$ref": "DisplayType"
"$ref": "DisplayType",
"typeScriptEnum": "DESTINATION|ROUTE_NUMBER|DEPARTURE_INDEX|NEXT_STATION|NEXT_STATION_KCR|NEXT_STATION_MTR|NEXT_STATION_UK"
},
"displayDefaultText": {
"type": "string"
Expand All @@ -71,7 +75,8 @@
"type": "number"
},
"doorAnimationType": {
"$ref": "DoorAnimationType"
"$ref": "DoorAnimationType",
"typeScriptEnum": "STANDARD|STANDARD_SLOW|CONSTANT|PLUG_FAST|PLUG_SLOW|BOUNCY_1|BOUNCY_2|MLR|R179|R211"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"javaImplements": [
"SerializedDataBase"
],
"typeScriptEditable": true,
"properties": {
"positionDefinition": {
"$ref": "positionDefinition.json"
},
"condition": {
"$ref": "PartCondition",
"typeScriptEnum": "NORMAL|AT_DEPOT|ON_ROUTE_FORWARDS|ON_ROUTE_BACKWARDS|DOORS_CLOSED|DOORS_OPENED|CHRISTMAS_LIGHT_RED|CHRISTMAS_LIGHT_YELLOW|CHRISTMAS_LIGHT_GREEN|CHRISTMAS_LIGHT_BLUE"
},
"renderStage": {
"$ref": "RenderStage",
"typeScriptEnum": "LIGHT|ALWAYS_ON_LIGHT|INTERIOR|INTERIOR_TRANSLUCENT|EXTERIOR"
},
"type": {
"$ref": "PartType",
"typeScriptEnum": "NORMAL|DISPLAY|FLOOR|DOORWAY|SEAT"
},
"displayXPadding": {
"type": "number",
"minimum": 0
},
"displayYPadding": {
"type": "number",
"minimum": 0
},
"displayColorCjk": {
"type": "string"
},
"displayColor": {
"type": "string"
},
"displayMaxLineHeight": {
"type": "number",
"minimum": 0
},
"displayCjkSizeRatio": {
"type": "number",
"minimum": 0
},
"displayOptions": {
"type": "array",
"items": {
"type": "string"
}
},
"displayPadZeros": {
"type": "number",
"minimum": 0
},
"displayType": {
"$ref": "DisplayType",
"typeScriptEnum": "DESTINATION|ROUTE_NUMBER|DEPARTURE_INDEX|NEXT_STATION|NEXT_STATION_KCR|NEXT_STATION_MTR|NEXT_STATION_UK"
},
"displayDefaultText": {
"type": "string"
},
"doorXMultiplier": {
"type": "number"
},
"doorZMultiplier": {
"type": "number"
},
"doorAnimationType": {
"$ref": "DoorAnimationType",
"typeScriptEnum": "STANDARD|STANDARD_SLOW|CONSTANT|PLUG_FAST|PLUG_SLOW|BOUNCY_1|BOUNCY_2|MLR|R179|R211"
}
},
"required": [
"positionDefinition",
"condition",
"renderStage",
"type",
"displayXPadding",
"displayYPadding",
"displayColorCjk",
"displayColor",
"displayMaxLineHeight",
"displayCjkSizeRatio",
"displayPadZeros",
"displayType",
"displayDefaultText",
"doorXMultiplier",
"doorZMultiplier",
"doorAnimationType"
]
}
21 changes: 21 additions & 0 deletions buildSrc/src/main/resources/schema/resource/modelWrapper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"javaImplements": [
"SerializedDataBase"
],
"properties": {
"id": {
"type": "string"
},
"modelParts": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"id"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"javaImplements": [
"SerializedDataBase"
],
"javaConstructorFields": [
"resourceProvider"
],
"properties": {
"id": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"javaImplements": [
"SerializedDataBase"
],
"typeScriptEditable": true,
"properties": {
"name": {
"type": "string"
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/resources/schema/resource/railResource.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"javaImplements": [
"SerializedDataBase"
],
"javaConstructorFields": [
"resourceProvider"
],
"properties": {
"id": {
"type": "string"
Expand Down
Loading

0 comments on commit 5d407ac

Please sign in to comment.