Add API to skip blockstate/model scanning for specific models
This commit is contained in:
parent
8b698452fd
commit
cb6ff1d68b
|
|
@ -0,0 +1,20 @@
|
|||
package org.embeddedt.modernfix.fabric.api.dynresources;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ModelScanController {
|
||||
public static final List<Predicate<ResourceLocation>> SCAN_PREDICATES = new ArrayList<>();
|
||||
public static boolean shouldScanAndTestWrapping(ResourceLocation location) {
|
||||
if(SCAN_PREDICATES.size() > 0) {
|
||||
for(Predicate<ResourceLocation> predicate : SCAN_PREDICATES) {
|
||||
if(!predicate.test(location))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,7 @@ import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration;
|
|||
import org.embeddedt.modernfix.duck.IExtendedModelBakery;
|
||||
import org.embeddedt.modernfix.dynamicresources.DynamicBakedModelProvider;
|
||||
import org.embeddedt.modernfix.dynamicresources.ModelBakeryHelpers;
|
||||
import org.embeddedt.modernfix.fabric.api.dynresources.ModelScanController;
|
||||
import org.embeddedt.modernfix.fabric.bridge.ModelV0Bridge;
|
||||
import org.embeddedt.modernfix.util.LayeredForwardingMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
@ -174,6 +175,13 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
|
||||
private boolean forceLoadModel = false;
|
||||
|
||||
@Inject(method = "loadTopLevel", at = @At("HEAD"), cancellable = true)
|
||||
private void ignoreRejectedModel(ModelResourceLocation location, CallbackInfo ci) {
|
||||
if(this.inTextureGatheringPass && !this.forceLoadModel && !ModelScanController.shouldScanAndTestWrapping(location)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "loadModel", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void ignoreNonFabricModel(ResourceLocation modelLocation, CallbackInfo ci) throws Exception {
|
||||
if(this.inTextureGatheringPass && !this.forceLoadModel && !this.injectedModels.contains(modelLocation)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user