Skip to content

Commit

Permalink
- 尝试修复 #19 x2。
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Nov 3, 2024
1 parent bbd8cc1 commit b6df448
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package github.kasuminova.stellarcore.client.integration.railcraft;

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.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;

import javax.annotation.Nullable;
import java.util.Set;
import java.util.function.Function;

public class RCModelBaker {

@Nullable
public static IBakedModel load(final Set<ModelResourceLocation> modelRL, final IModel model, Function<ResourceLocation, TextureAtlasSprite> textureGetter) {
boolean detected = false;
for (final ModelResourceLocation rl : modelRL) {
if (rl.getNamespace().startsWith("railcraft")) {
detected = true;
break;
}
}
if (detected) {
synchronized (RCModelBaker.class) {
return model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ 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
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap;
import com.llamalad7.mixinextras.sugar.Local;
import github.kasuminova.stellarcore.client.integration.railcraft.RCModelBaker;
import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
import github.kasuminova.stellarcore.common.util.ClassUtils;
import github.kasuminova.stellarcore.common.util.StellarLog;
Expand Down Expand Up @@ -95,8 +96,10 @@ private void injectInit(final IResourceManager resourceManagerIn, final TextureM
long startTime = System.currentTimeMillis();

Map<IModel, IBakedModel> bakedModelsConcurrent = new NonBlockingHashMap<>();
DefaultTextureGetter textureGetter = new DefaultTextureGetter();
models.keySet().stream().parallel().forEach((model) -> {
String modelLocations = "[" + Joiner.on(", ").join(models.get(model)) + "]";
Set<ModelResourceLocation> locations = models.get(model);
String modelLocations = "[" + Joiner.on(", ").join(locations) + "]";
synchronized (bakeBar) {
bakeBar.step(modelLocations);
}
Expand All @@ -107,7 +110,12 @@ private void injectInit(final IResourceManager resourceManagerIn, final TextureM
}

try {
bakedModelsConcurrent.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, new DefaultTextureGetter()));
IBakedModel loaded = RCModelBaker.load(locations, model, textureGetter);
if (loaded != null) {
bakedModelsConcurrent.put(model, loaded);
return;
}
bakedModelsConcurrent.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter));
} catch (Exception e) {
if (!StellarCoreConfig.FEATURES.vanilla.shutUpModelLoader) {
FMLLog.log.error("Exception baking model for location(s) {}:", modelLocations, e);
Expand Down

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/resources/mixins.stellar_core_railcraft.json

This file was deleted.

0 comments on commit b6df448

Please sign in to comment.