Skip to content

Commit

Permalink
- 尝试修复 #19
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Nov 2, 2024
1 parent 8367380 commit bbd8cc1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ModelResourceLocation, IBakedModel> models,
final VertexFormat format,
final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter,
final Map<IBlockState, ModelResourceLocation> 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<ModelResourceLocation, IBakedModel> model, final VertexFormat modelLocation, final Function<ResourceLocation, TextureAtlasSprite> models, final Map<IBlockState, ModelResourceLocation> format) {
synchronized (ActuatorModel.class) {
bakeModels(model, modelLocation, models, format);
}
}

}
Original file line number Diff line number Diff line change
@@ -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<ModelResourceLocation, IBakedModel> bakeModels(
final VertexFormat format,
final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter,
final Set<ModelResourceLocation> 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<ModelResourceLocation, IBakedModel> injectBakeModels(final OutfittedTrackModel instance, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, final Set<ModelResourceLocation> modelLocations) {
synchronized (ActuatorModel.class) {
return bakeModels(format, bakedTextureGetter, modelLocations);
}
}

}
11 changes: 11 additions & 0 deletions src/main/resources/mixins.stellar_core_railcraft.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit bbd8cc1

Please sign in to comment.