Merge remote-tracking branch 'origin/main' into 1.18
This commit is contained in:
commit
e724cbfa63
|
|
@ -33,6 +33,7 @@ dependencies {
|
|||
modIncludeImplementation(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-command-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-models-v0", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modImplementation(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modCompileOnly("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { transitive false }
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.google.common.cache.RemovalNotification;
|
||||
import com.google.common.collect.ForwardingMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.math.Transformation;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.fabricmc.fabric.impl.client.model.ModelLoadingRegistryImpl;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.BlockModelDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
|
||||
|
|
@ -105,6 +104,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
|
||||
private boolean inTextureGatheringPass;
|
||||
|
||||
private Set<ResourceLocation> injectedModels;
|
||||
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;push(Ljava/lang/String;)V", ordinal = 0))
|
||||
private void replaceTopLevelBakedModels(ProfilerFiller filler, String s) {
|
||||
this.inTextureGatheringPass = true;
|
||||
|
|
@ -137,6 +138,10 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
}
|
||||
};
|
||||
filler.push(s);
|
||||
this.injectedModels = new ObjectOpenHashSet<>();
|
||||
ModelLoadingRegistryImpl.LoaderInstance instance = ModelLoadingRegistryImpl.begin((ModelBakery)(Object)this, this.resourceManager);
|
||||
instance.onModelPopulation(this.injectedModels::add);
|
||||
instance.finish();
|
||||
}
|
||||
|
||||
private <K, V> void onModelRemoved(RemovalNotification<K, V> notification) {
|
||||
|
|
@ -169,9 +174,9 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
|
||||
private boolean forceLoadModel = false;
|
||||
|
||||
@Inject(method = "loadModel", at = @At(value = "HEAD", shift = At.Shift.AFTER), cancellable = true)
|
||||
@Inject(method = "loadModel", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void ignoreNonFabricModel(ResourceLocation modelLocation, CallbackInfo ci) throws Exception {
|
||||
if(this.inTextureGatheringPass && !this.forceLoadModel) {
|
||||
if(this.inTextureGatheringPass && !this.forceLoadModel && !this.injectedModels.contains(modelLocation)) {
|
||||
// Custom model processor, try to avoid loading unwrapped models
|
||||
// First add this to the list of models to scan for textures
|
||||
ResourceLocation blockStateLocation = null;
|
||||
|
|
@ -187,7 +192,6 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
modelFiles.add(modelLocation);
|
||||
// Now check if it's a wrapped model
|
||||
boolean isWrappedModel = false;
|
||||
Set<ResourceLocation> oldLoadingStack = this.loadingStack.size() > 0 ? new ObjectOpenHashSet<>(this.loadingStack) : ImmutableSet.of();
|
||||
// Set the correct blockstate context
|
||||
StateDefinition<Block, BlockState> statecontainer;
|
||||
if(blockStateLocation != null) {
|
||||
|
|
@ -202,8 +206,6 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
this.forceLoadModel = true;
|
||||
this.cacheAndQueueDependencies(modelLocation, this.missingModel);
|
||||
this.forceLoadModel = false;
|
||||
this.loadingStack.clear();
|
||||
this.loadingStack.addAll(oldLoadingStack);
|
||||
if(this.smallLoadingCache.get(modelLocation) != this.missingModel) {
|
||||
/* probably a wrapped model, allow it to load normally */
|
||||
isWrappedModel = true;
|
||||
|
|
@ -265,6 +267,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
private void skipBake(TextureManager resourceManager, ProfilerFiller profiler, CallbackInfoReturnable<AtlasSet> cir) {
|
||||
profiler.pop();
|
||||
this.inTextureGatheringPass = false;
|
||||
this.injectedModels = null;
|
||||
// hand off to the dynamic model system
|
||||
this.loadedModels.put(MISSING_MODEL_LOCATION, this.missingModel);
|
||||
this.bakedCache = loadedBakedModels.asMap();
|
||||
|
|
@ -394,6 +397,8 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
|
||||
private BakedModel bakedMissingModel = null;
|
||||
|
||||
private Set<ResourceLocation> bakeStack = new LinkedHashSet<>();
|
||||
|
||||
@Inject(method = "bake", at = @At("HEAD"), cancellable = true)
|
||||
public void getOrLoadBakedModelDynamic(ResourceLocation arg, ModelState arg2, CallbackInfoReturnable<BakedModel> cir) {
|
||||
Function<Material, TextureAtlasSprite> textureGetter = mat -> this.atlasSet.getSprite(mat);
|
||||
|
|
@ -408,8 +413,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
if(debugDynamicModelLoading)
|
||||
LOGGER.info("Baking {}", arg);
|
||||
UnbakedModel iunbakedmodel = this.getModel(arg);
|
||||
Set<Pair<String, String>> errorSet = new HashSet<>();
|
||||
Collection<Material> theMaterials = iunbakedmodel.getMaterials(this::getModel, errorSet);
|
||||
Collection<Material> theMaterials = iunbakedmodel.getMaterials(this::getModel, new HashSet<>());
|
||||
/* check if sprites are actually present */
|
||||
TextureAtlasSprite missingSprite = this.atlasSet.getAtlas(TextureAtlas.LOCATION_BLOCKS).getSprite(MissingTextureAtlasSprite.getLocation());
|
||||
for(Material m : theMaterials) {
|
||||
|
|
@ -419,7 +423,6 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
ModernFix.LOGGER.warn("Texture {} is not present in blocks atlas", m.texture());
|
||||
}
|
||||
}
|
||||
errorSet.stream().filter(pair -> !pair.getSecond().equals(MISSING_MODEL_LOCATION_STRING)).forEach(pair -> LOGGER.warn("Unable to resolve texture reference: {} in {}", pair.getFirst(), pair.getSecond()));
|
||||
|
||||
if(iunbakedmodel == missingModel && debugDynamicModelLoading)
|
||||
LOGGER.warn("Model {} not present", arg);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-screen-api-v1": "*",
|
||||
"fabric-command-api-v1": "*",
|
||||
"fabric-models-v0": "*",
|
||||
"minecraft": ">=1.16.5"
|
||||
},
|
||||
"breaks": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user