CTM compat fix

This commit is contained in:
paulevsGitch 2021-07-31 09:22:21 +03:00
parent 05b89607a5
commit 24ce3fa4e8
2 changed files with 14 additions and 6 deletions

View file

@ -41,7 +41,6 @@ public interface BlockModelProvider extends ItemModelProvider {
} }
else { else {
BCLib.LOGGER.warning("Error loading model: {}", modelId); BCLib.LOGGER.warning("Error loading model: {}", modelId);
modelCache.put(modelId, modelCache.get(MISSING_MODEL_LOCATION));
} }
} }
} }

View file

@ -25,6 +25,7 @@ import ru.bclib.interfaces.BlockModelProvider;
import ru.bclib.interfaces.ItemModelProvider; import ru.bclib.interfaces.ItemModelProvider;
import java.util.Map; import java.util.Map;
import java.util.Set;
@Mixin(ModelBakery.class) @Mixin(ModelBakery.class)
public abstract class ModelBakeryMixin { public abstract class ModelBakeryMixin {
@ -34,20 +35,22 @@ public abstract class ModelBakeryMixin {
@Final @Final
@Shadow @Shadow
private Map<ResourceLocation, UnbakedModel> topLevelModels; private Map<ResourceLocation, UnbakedModel> topLevelModels;
@Final
//private Map<ResourceLocation, UnbakedModel> cache = Maps.newHashMap(); @Shadow
//private Map<ResourceLocation, UnbakedModel> topLevel = Maps.newHashMap(); private Set<ResourceLocation> loadingStack;
@Inject( @Inject(
method = "<init>*", method = "<init>*",
at = @At( at = @At(
value = "INVOKE_STRING", value = "INVOKE_STRING",
target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", target = "Lnet/minecraft/util/profiling/ProfilerFiller;push(Ljava/lang/String;)V",
args = "ldc=static_definitions", args = "ldc=missing_model",
shift = Shift.BEFORE shift = Shift.BEFORE
) )
) )
private void bclib_initCustomModels(ResourceManager resourceManager, BlockColors blockColors, ProfilerFiller profiler, int mipmap, CallbackInfo info) { private void bclib_initCustomModels(ResourceManager resourceManager, BlockColors blockColors, ProfilerFiller profiler, int mipmap, CallbackInfo info) {
System.out.println("Cache size 1: " + unbakedCache.size());
Map<ResourceLocation, UnbakedModel> cache = Maps.newConcurrentMap(); Map<ResourceLocation, UnbakedModel> cache = Maps.newConcurrentMap();
Map<ResourceLocation, UnbakedModel> topLevel = Maps.newConcurrentMap(); Map<ResourceLocation, UnbakedModel> topLevel = Maps.newConcurrentMap();
@ -102,6 +105,12 @@ public abstract class ModelBakeryMixin {
} }
}); });
System.out.println("Cache size 2: " + unbakedCache.size());
cache.values().forEach(model -> {
loadingStack.addAll(model.getDependencies());
});
topLevelModels.putAll(topLevel); topLevelModels.putAll(topLevel);
unbakedCache.putAll(cache); unbakedCache.putAll(cache);
} }