Skip to content

Commit

Permalink
Merge branch 'zbx1425:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dooji2 authored Apr 25, 2024
2 parents 423724e + 3878527 commit a4c4f12
Show file tree
Hide file tree
Showing 68 changed files with 998 additions and 412 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
# push:
# branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: 'docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
75 changes: 4 additions & 71 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.json.JsonSlurper
import org.apache.tools.ant.filters.ReplaceTokens

import java.time.Instant
Expand All @@ -13,56 +11,7 @@ plugins {
id "base"
}

String default_minecraft_version = "1.19.2"
Properties localProperties = new Properties()
String minecraft_version
if (project.rootProject.file('build.properties').exists()) {
localProperties.load(project.rootProject.file('build.properties').newDataInputStream())
}
if (localProperties.containsKey("MC_VERSION")) {
String notDotted = localProperties.get("MC_VERSION")
String dotted = notDotted.substring(0, 1) + "." +
Integer.toString(Integer.parseInt(notDotted.substring(1, 3))) + "." +
Integer.toString(Integer.parseInt(notDotted.substring(3, 5)))
minecraft_version = dotted
} else {
minecraft_version = rootProject.properties.containsKey("buildVersion") ? rootProject.properties.get("buildVersion") : default_minecraft_version
}
rootProject.ext.minecraft_main_version = minecraft_version.split("\\.")[1] as int
String minecraft_version_int = minecraft_version.split("\\.")[0] +
minecraft_version.split("\\.")[1].padLeft(2, '0') +
(minecraft_version.split("\\.").length > 2 ? minecraft_version.split("\\.")[2].padLeft(2, '0') : "00")
boolean parchment_not_avail = false
String parchment_version = parchment_not_avail ? "N/A" : new XmlSlurper().parse("https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-${minecraft_version}/maven-metadata.xml").versioning.release
def is_1_19_3 = minecraft_version == "1.19.3" || minecraft_version == "1.19.4"
def is_1_20 = minecraft_version == "1.20" || minecraft_version == "1.20.1"

rootProject.ext.fabric_loader_version = new JsonSlurper().parse(("https://meta.fabricmc.net/v2/versions/loader/" + minecraft_version).toURL())[0]["loader"]["version"]
rootProject.ext.forge_version = minecraft_version + "-" + new JsonSlurper().parse(("https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json").toURL())["promos"][minecraft_version + "-recommended"]
rootProject.ext.fabric_api_version = getModrinthVersion("fabric", minecraft_version, "fabric-api")
rootProject.ext.mod_menu_version = getModrinthVersion("fabric", minecraft_version, "modmenu")
rootProject.ext.architectury_version = getModrinthVersion("forge", minecraft_version, "architectury-api").split("\\+")[0]
rootProject.ext.architectury_id = minecraft_main_version == 16 ? "me.shedaniel" : "dev.architectury"

rootProject.ext.supports_minecraft_version = [
"1.16.5": "1.16.x",
"1.17.1": "1.17.x", "1.18.2": "1.18.x",
"1.19.2": "1.19.2", "1.19.3": "1.19.3", "1.19.4": "1.19.4",
"1.20.1": "1.20.x"
][minecraft_version]
rootProject.ext.supports_minecraft_version_range = [
"1.16.5": "[1.16, 1.17)",
"1.17.1": "[1.17, 1.18)", "1.18.2": "[1.18, 1.19)",
"1.19.2": "1.19.2", "1.19.3": "1.19.3", "1.19.4": "1.19.4",
"1.20.1": "[1.20, 1.21)"
][minecraft_version]
rootProject.ext.cloth_config_version = [
"1.16.5": "4.17.101",
"1.17.1": "5.3.63", "1.18.2": "6.5.102",
"1.19.2": "8.3.103", "1.19.3": "9.1.104", "1.19.4": "10.1.105",
"1.20.1": "11.1.106"
][minecraft_version]
rootProject.ext.mtr_min_version = minecraft_version + "-" + rootProject.mtr_min_version
apply from: "build_dep_ver.gradle"

rootProject.ext.assetExcludeFont = rootProject.properties.containsKey("assetExcludeFont")

Expand All @@ -84,7 +33,7 @@ configure(subprojects.findAll {it.name != 'rhino'}) {
dependencies {
annotationProcessor 'systems.manifold:manifold-preprocessor:+'
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings parchment_not_avail ? loom.officialMojangMappings() : loom.layered() {
mappings parchment_version == "" ? loom.officialMojangMappings() : loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
}
Expand Down Expand Up @@ -123,7 +72,7 @@ task setupLibrary() {
}
}

String minecraftMappingsBaseURL = is_1_20 ? "https://storage.zbx1425.cn/mtr-artifacts/Minecraft-Mappings/" : "https://github.com/jonafanho/Minecraft-Mappings/archive/refs/heads/"
String minecraftMappingsBaseURL = "https://github.com/zbx1425/Minecraft-Mappings/archive/refs/heads/"

download {
src "${minecraftMappingsBaseURL}${is_1_19_3 ? minecraft_version : "1." + minecraft_main_version}.zip"
Expand Down Expand Up @@ -215,22 +164,6 @@ configure(allprojects.findAll {it.name != 'rhino'}) {
}
}

static def getModrinthVersion(loader, minecraftVersion, projectId) {
def versionsArray = new JsonSlurper().parse(("https://api.modrinth.com/v2/project/" + projectId + "/version").toURL())
for (def versionElement : versionsArray) {
if (versionElement["loaders"].contains(loader) && versionElement["game_versions"].contains(minecraftVersion)) {
return versionElement["version_number"]
}
}
return ""
}

static def getParchmentVersion(minecraftVersion) {
def url = "https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-" + minecraftVersion + "/maven-metadata.xml"
def data = new XmlParser().parse(url)
return data.versioning.latest.text()
}

forgix {
group = "cn.zbx1425"
mergedJarName = "MTR-NTE" + "-" + rootProject.mod_version + "+" + minecraft_version + ".jar"
Expand Down Expand Up @@ -265,7 +198,7 @@ class DummyArchiveTask extends AbstractArchiveTask {
}
}

task dummyForgixOutput(type: DummyArchiveTask) {
tasks.register('dummyForgixOutput', DummyArchiveTask) {
// Forgix's mergeJars task doesn't extend AbstractArchiveTask.
// This is to make github.com/teaconmc/longjing happy.
destinationDirectory = file("build/")
Expand Down
81 changes: 81 additions & 0 deletions build_dep_ver.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
String default_minecraft_version = "1.19.2"
Properties localProperties = new Properties()
String minecraft_version
if (project.rootProject.file('build.properties').exists()) {
localProperties.load(project.rootProject.file('build.properties').newDataInputStream())
}
if (rootProject.properties.containsKey("buildVersion")) {
minecraft_version = rootProject.properties.get("buildVersion")
} else if (localProperties.containsKey("MC_VERSION")) {
String notDotted = localProperties.get("MC_VERSION")
String dotted = notDotted.substring(0, 1) + "." +
Integer.toString(Integer.parseInt(notDotted.substring(1, 3))) + "." +
Integer.toString(Integer.parseInt(notDotted.substring(3, 5)))
minecraft_version = dotted
} else {
minecraft_version = default_minecraft_version
}
rootProject.ext.minecraft_version = minecraft_version
rootProject.ext.minecraft_main_version = minecraft_version.split("\\.")[1] as int
rootProject.ext.minecraft_version_int = minecraft_version.split("\\.")[0] +
minecraft_version.split("\\.")[1].padLeft(2, '0') +
(minecraft_version.split("\\.").length > 2 ? minecraft_version.split("\\.")[2].padLeft(2, '0') : "00")
rootProject.ext.is_1_19_3 = minecraft_version == "1.19.3" || minecraft_version == "1.19.4"
rootProject.ext.is_1_20 = minecraft_version == "1.20" || minecraft_version == "1.20.1"

rootProject.ext.supports_minecraft_version = [
"1.16.5": "1.16.x",
"1.17.1": "1.17.x", "1.18.2": "1.18.x",
"1.19.2": "1.19.2", "1.19.3": "1.19.3", "1.19.4": "1.19.4",
"1.20.1": "1.20.x"
][minecraft_version]
rootProject.ext.supports_minecraft_version_range = [
"1.16.5": "[1.16, 1.17)",
"1.17.1": "[1.17, 1.18)", "1.18.2": "[1.18, 1.19)",
"1.19.2": "1.19.2", "1.19.3": "1.19.3", "1.19.4": "1.19.4",
"1.20.1": "[1.20, 1.21)"
][minecraft_version]

rootProject.ext.parchment_version = [
"1.16.5": "2022.03.06",
"1.17.1": "2021.12.12", "1.18.2": "2022.11.06",
"1.19.2": "2022.11.27", "1.19.3": "2023.06.25", "1.19.4": "2023.06.26",
"1.20.1": "2023.09.03"
][minecraft_version]

rootProject.ext.fabric_loader_version = "0.15.3"
rootProject.ext.fabric_api_version = [
"1.16.5": "0.42.0",
"1.17.1": "0.46.1+1.17", "1.18.2": "0.77.0+1.18.2",
"1.19.2": "0.77.0+1.19.2", "1.19.3": "0.76.1+1.19.3", "1.19.4": "0.87.2+1.19.4",
"1.20.1": "0.91.0+1.20.1"
][minecraft_version]
rootProject.ext.mod_menu_version = [
"1.16.5": "1.16.23",
"1.17.1": "2.0.17", "1.18.2": "3.2.5",
"1.19.2": "4.1.2", "1.19.3": "5.1.0", "1.19.4": "6.3.1",
"1.20.1": "7.2.2"
][minecraft_version]

rootProject.ext.forge_version = minecraft_version + "-" + [
"1.16.5": "36.2.34",
"1.17.1": "37.1.1", "1.18.2": "40.2.0",
"1.19.2": "43.3.0", "1.19.3": "44.1.0", "1.19.4": "45.2.0",
"1.20.1": "47.2.0"
][minecraft_version]
rootProject.ext.architectury_version = [
"1.16.5": "1.32.68",
"1.17.1": "2.10.12", "1.18.2": "4.11.93",
"1.19.2": "6.5.85", "1.19.3": "7.1.86", "1.19.4": "8.2.89",
"1.20.1": "9.1.12"
][minecraft_version]
rootProject.ext.architectury_id = minecraft_main_version == 16 ? "me.shedaniel" : "dev.architectury"

rootProject.ext.mtr_min_version = minecraft_version == "1.20.1" ? "0" : minecraft_version + "-" + rootProject.mtr_min_version

rootProject.ext.cloth_config_version = [
"1.16.5": "4.17.101",
"1.17.1": "5.3.63", "1.18.2": "6.5.102",
"1.19.2": "8.3.103", "1.19.3": "9.1.104", "1.19.4": "10.1.105",
"1.20.1": "11.1.106"
][minecraft_version]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ClientConfig {

public static boolean enableOptimization = true;
public static boolean enableBbModelPreload = false;
public static boolean translucentSort = true;
public static boolean translucentSort = false;

public static boolean enableScriptDebugOverlay = false;

Expand All @@ -37,7 +37,7 @@ public static void load(Path path) {
JsonObject configObject = Main.JSON_PARSER.parse(Files.readString(path)).getAsJsonObject();
enableOptimization = !getOrDefault(configObject, "shaderCompatMode", JsonElement::getAsBoolean, false);
enableBbModelPreload = getOrDefault(configObject, "enableBbModelPreload", JsonElement::getAsBoolean, false);
translucentSort = getOrDefault(configObject, "translucentSort", JsonElement::getAsBoolean, true);
translucentSort = getOrDefault(configObject, "translucentSort", JsonElement::getAsBoolean, false);
enableScriptDebugOverlay = getOrDefault(configObject, "enableScriptDebugOverlay", JsonElement::getAsBoolean, false);
enableRail3D = getOrDefault(configObject, "enableRail3D", JsonElement::getAsBoolean, true);
enableRailRender = getOrDefault(configObject, "enableRailRender", JsonElement::getAsBoolean, true);
Expand Down
22 changes: 13 additions & 9 deletions common/src/main/java/cn/zbx1425/mtrsteamloco/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import com.google.gson.JsonParser;
import mtr.CreativeModeTabs;
import mtr.RegistryObject;
import mtr.item.ItemBridgeCreator;
import mtr.item.ItemWithCreativeTabBase;
import mtr.mappings.BlockEntityMapper;
import mtr.mappings.RegistryUtilities;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -53,22 +56,23 @@ public class Main {
BLOCK_EYE_CANDY.get()
));

public static final RegistryObject<ItemWithCreativeTabBase> BRIDGE_CREATOR_1 = new RegistryObject<>(() -> new ItemBridgeCreator(1));

public static final SoundEvent SOUND_EVENT_BELL = RegistryUtilities.createSoundEvent(new ResourceLocation("mtrsteamloco:bell"));

public static SimpleParticleType PARTICLE_STEAM_SMOKE;

public static void init(
RegisterBlockItem registerBlockItem,
BiConsumer<String,RegistryObject<? extends BlockEntityType<? extends BlockEntityMapper>>> registerBlockEntityType,
BiConsumer<String, SoundEvent> registerSoundEvent
) {
public static void init(RegistriesWrapper registries) {
LOGGER.info("MTR-NTE " + BuildConfig.MOD_VERSION + " built at "
+ DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.systemDefault()).format(BuildConfig.BUILD_TIME));
if (enableRegistry) {
registerBlockItem.accept("departure_bell", BLOCK_DEPARTURE_BELL, CreativeModeTabs.RAILWAY_FACILITIES);
registerBlockItem.accept("eye_candy", BLOCK_EYE_CANDY, CreativeModeTabs.STATION_BUILDING_BLOCKS);
registerBlockEntityType.accept("eye_candy", BLOCK_ENTITY_TYPE_EYE_CANDY);
registerSoundEvent.accept("bell", SOUND_EVENT_BELL);
registries.registerBlockAndItem("departure_bell", BLOCK_DEPARTURE_BELL, CreativeModeTabs.RAILWAY_FACILITIES);
registries.registerBlockAndItem("eye_candy", BLOCK_EYE_CANDY, CreativeModeTabs.STATION_BUILDING_BLOCKS);
registries.registerBlockEntityType("eye_candy", BLOCK_ENTITY_TYPE_EYE_CANDY);
registries.registerItem("bridge_creator_1", BRIDGE_CREATOR_1);
registries.registerSoundEvent("bell", SOUND_EVENT_BELL);
PARTICLE_STEAM_SMOKE = registries.createParticleType(true);
registries.registerParticleType("steam_smoke", PARTICLE_STEAM_SMOKE);

mtr.Registry.registerNetworkReceiver(PacketUpdateBlockEntity.PACKET_UPDATE_BLOCK_ENTITY,
PacketUpdateBlockEntity::receiveUpdateC2S);
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/cn/zbx1425/mtrsteamloco/MainClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import cn.zbx1425.mtrsteamloco.render.ShadersModHandler;
import cn.zbx1425.mtrsteamloco.render.block.BlockEntityEyeCandyRenderer;
import cn.zbx1425.mtrsteamloco.render.rail.RailRenderDispatcher;
import cn.zbx1425.sowcer.util.Profiler;
import cn.zbx1425.sowcer.util.DrawContext;
import cn.zbx1425.sowcerext.reuse.AtlasManager;
import cn.zbx1425.sowcerext.reuse.DrawScheduler;
import cn.zbx1425.sowcerext.reuse.ModelManager;
import mtr.RegistryClient;
import mtr.item.ItemBlockClickingBase;

public class MainClient {

Expand All @@ -19,7 +20,7 @@ public class MainClient {

public static RailRenderDispatcher railRenderDispatcher = new RailRenderDispatcher();

public static Profiler profiler = new Profiler();
public static DrawContext drawContext = new DrawContext();

public static void init() {
ClientConfig.load();
Expand All @@ -32,9 +33,8 @@ public static void init() {

RegistryClient.registerNetworkReceiver(PacketVersionCheck.PACKET_VERSION_CHECK, PacketVersionCheck::receiveVersionCheckS2C);
RegistryClient.registerNetworkReceiver(PacketScreen.PACKET_SHOW_SCREEN, PacketScreen::receiveScreenS2C);
// RegistryClient.registerBlockRenderType(RenderType.cutout(), Main.BLOCK_EYE_CANDY.get());

// RegistryClient.registerBlockRenderType(RenderType.cutout(), Main.BLOCK_STATISTIC_TURNSTILE.get());
RegistryClient.registerItemModelPredicate("mtr:selected", Main.BRIDGE_CREATOR_1.get(), ItemBlockClickingBase.TAG_POS);
}

RegistryClient.registerPlayerJoinEvent(localPlayer -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cn.zbx1425.mtrsteamloco;

import mtr.CreativeModeTabs;
import mtr.RegistryObject;
import mtr.item.ItemWithCreativeTabBase;
import net.minecraft.client.KeyMapping;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.resources.ResourceKey;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;

public interface RegistriesWrapper {

void registerBlock(String id, RegistryObject<Block> block);

void registerItem(String id, RegistryObject<ItemWithCreativeTabBase> item);

void registerBlockAndItem(String id, RegistryObject<Block> block, CreativeModeTabs.Wrapper tab);

void registerBlockEntityType(String id, RegistryObject<? extends BlockEntityType<? extends BlockEntity>> blockEntityType);

void registerEntityType(String id, RegistryObject<? extends EntityType<? extends Entity>> entityType);

void registerSoundEvent(String id, SoundEvent soundEvent);

void registerParticleType(String id, ParticleType<?> particleType);

SimpleParticleType createParticleType(boolean overrideLimiter);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.zbx1425.mtrsteamloco.Main;
import cn.zbx1425.mtrsteamloco.network.PacketScreen;
import cn.zbx1425.mtrsteamloco.render.scripting.eyecandy.EyeCandyScriptContext;
import cn.zbx1425.sowcer.math.Vector3f;
import mtr.mappings.BlockDirectionalMapper;
import mtr.mappings.BlockEntityClientSerializableMapper;
import mtr.mappings.BlockEntityMapper;
Expand Down Expand Up @@ -119,5 +120,9 @@ public void writeCompoundTag(CompoundTag compoundTag) {
public BlockPos getWorldPos() {
return this.worldPosition;
}

public Vector3f getWorldPosVector3f() {
return new Vector3f(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
}
}
}
Loading

0 comments on commit a4c4f12

Please sign in to comment.