Merge remote-tracking branch 'origin/1.20' into 1.21.1

This commit is contained in:
embeddedt 2025-05-15 21:26:09 -04:00
commit 8a3b7f7935
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package org.embeddedt.modernfix.common.mixin.perf.model_optimizations;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.renderer.block.model.Variant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.List;
import java.util.function.Function;
@Mixin(value = MultiVariant.class, priority = 700)
@ClientOnlyMixin
public abstract class MultiVariantMixin {
@Shadow public abstract List<Variant> getVariants();
/**
* @author embeddedt
* @reason avoid streams, try to optimize for common case
*/
@Overwrite
public void resolveParents(Function<ResourceLocation, UnbakedModel> modelGetter) {
var variants = this.getVariants();
// There is usually only a single variant
if (variants.size() == 1) {
modelGetter.apply(variants.get(0).getModelLocation()).resolveParents(modelGetter);
} else if(variants.size() > 1) {
ObjectOpenHashSet<ResourceLocation> seenLocations = new ObjectOpenHashSet<>(variants.size());
for (var variant : variants) {
var location = variant.getModelLocation();
if (seenLocations.add(location)) {
modelGetter.apply(location).resolveParents(modelGetter);
}
}
}
}
}

View File

@ -165,6 +165,7 @@ public class ModelBakeEventHelper {
modIdsToInclude.remove("minecraft");
Set<ModelResourceLocation> ourModelLocations;
if (config == UniverseVisibility.SELF_AND_DEPS) {
ModernFix.LOGGER.debug("Mod {} is restricted to seeing models from mods: [{}]", modId, String.join(", ", modIdsToInclude));
ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.id().getNamespace()));
} else {
ourModelLocations = this.topLevelModelLocations;