From bbd8cc105bb3c7dbd8929daff83d7addbe6ea819 Mon Sep 17 00:00:00 2001 From: Hikari_Nova <3044344887@qq.com> Date: Sat, 2 Nov 2024 17:50:24 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=20#19?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 3 +- .../mixin/StellarCoreLateMixinLoader.java | 1 + .../mixin/railcraft/MixinActuatorModel.java | 42 +++++++++++++++++++ .../railcraft/MixinOutfittedTrackModel.java | 42 +++++++++++++++++++ .../mixins.stellar_core_railcraft.json | 11 +++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinActuatorModel.java create mode 100644 src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinOutfittedTrackModel.java create mode 100644 src/main/resources/mixins.stellar_core_railcraft.json diff --git a/build.gradle.kts b/build.gradle.kts index 0917720..2883cff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { // Project properties group = "github.kasuminova.stellarcore" -version = "1.5.16" +version = "1.5.17" // Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod java { @@ -293,6 +293,7 @@ dependencies { compileOnly(rfg.deobf("curse.maven:dme-737252:5043404")) compileOnly(rfg.deobf("curse.maven:bountifulbaubles-313536:3568240")) compileOnly(rfg.deobf("curse.maven:special-mobs-59968:3320102")) + implementation(rfg.deobf("curse.maven:railcraft-51195:3853491")) } // IDE Settings diff --git a/src/main/java/github/kasuminova/stellarcore/mixin/StellarCoreLateMixinLoader.java b/src/main/java/github/kasuminova/stellarcore/mixin/StellarCoreLateMixinLoader.java index 65d672d..cbf0239 100644 --- a/src/main/java/github/kasuminova/stellarcore/mixin/StellarCoreLateMixinLoader.java +++ b/src/main/java/github/kasuminova/stellarcore/mixin/StellarCoreLateMixinLoader.java @@ -60,6 +60,7 @@ public class StellarCoreLateMixinLoader implements ILateMixinLoader { addModdedMixinCFG("mixins.stellar_core_modularrouters.json", "modularrouters"); addMixinCFG( "mixins.stellar_core_nco.json", Mods.NCO::loaded); addModdedMixinCFG("mixins.stellar_core_psi.json", "psi"); + addModdedMixinCFG("mixins.stellar_core_railcraft.json", "railcraft", () -> StellarCoreConfig.PERFORMANCE.vanilla.parallelModelLoader); addModdedMixinCFG("mixins.stellar_core_rgb_chat.json", "jianghun"); addModdedMixinCFG("mixins.stellar_core_scalingguis.json", "scalingguis"); addModdedMixinCFG("mixins.stellar_core_specialmobs.json", "specialmobs"); diff --git a/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinActuatorModel.java b/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinActuatorModel.java new file mode 100644 index 0000000..b1aa297 --- /dev/null +++ b/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinActuatorModel.java @@ -0,0 +1,42 @@ +package github.kasuminova.stellarcore.mixin.railcraft; + +import mods.railcraft.client.render.models.resource.ActuatorModel; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Map; +import java.util.function.Function; + +@SuppressWarnings("MethodMayBeStatic") +@Mixin(value = ActuatorModel.class, remap = false) +public abstract class MixinActuatorModel { + + @Shadow + private static void bakeModels(final Map models, + final VertexFormat format, + final Function bakedTextureGetter, + final Map modelLocations) { + } + + @Redirect( + method = "bake", + at = @At( + value = "INVOKE", + target = "Lmods/railcraft/client/render/models/resource/ActuatorModel;bakeModels(Ljava/util/Map;Lnet/minecraft/client/renderer/vertex/VertexFormat;Ljava/util/function/Function;Ljava/util/Map;)V" + ) + ) + private void injectBakeModels(final Map model, final VertexFormat modelLocation, final Function models, final Map format) { + synchronized (ActuatorModel.class) { + bakeModels(model, modelLocation, models, format); + } + } + +} diff --git a/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinOutfittedTrackModel.java b/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinOutfittedTrackModel.java new file mode 100644 index 0000000..64250dc --- /dev/null +++ b/src/main/java/github/kasuminova/stellarcore/mixin/railcraft/MixinOutfittedTrackModel.java @@ -0,0 +1,42 @@ +package github.kasuminova.stellarcore.mixin.railcraft; + +import mods.railcraft.client.render.models.resource.ActuatorModel; +import mods.railcraft.client.render.models.resource.OutfittedTrackModel; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +@Mixin(value = OutfittedTrackModel.class, remap = false) +public abstract class MixinOutfittedTrackModel { + + @Shadow + protected abstract Map bakeModels( + final VertexFormat format, + final Function bakedTextureGetter, + final Set modelLocations + ); + + @Redirect( + method = "bake", + at = @At( + value = "INVOKE", + target = "Lmods/railcraft/client/render/models/resource/OutfittedTrackModel;bakeModels(Lnet/minecraft/client/renderer/vertex/VertexFormat;Ljava/util/function/Function;Ljava/util/Set;)Ljava/util/Map;" + ) + ) + private Map injectBakeModels(final OutfittedTrackModel instance, final VertexFormat format, final Function bakedTextureGetter, final Set modelLocations) { + synchronized (ActuatorModel.class) { + return bakeModels(format, bakedTextureGetter, modelLocations); + } + } + +} diff --git a/src/main/resources/mixins.stellar_core_railcraft.json b/src/main/resources/mixins.stellar_core_railcraft.json new file mode 100644 index 0000000..a652224 --- /dev/null +++ b/src/main/resources/mixins.stellar_core_railcraft.json @@ -0,0 +1,11 @@ +{ + "package": "github.kasuminova.stellarcore.mixin.railcraft", + "refmap": "mixins.stellar_core.refmap.json", + "target": "@env(DEFAULT)", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "client": [ + "MixinActuatorModel", + "MixinOutfittedTrackModel" + ] +} \ No newline at end of file