Merge remote-tracking branch 'origin/1.20' into 1.21.1
This commit is contained in:
commit
8a3b7f7935
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -165,6 +165,7 @@ public class ModelBakeEventHelper {
|
||||||
modIdsToInclude.remove("minecraft");
|
modIdsToInclude.remove("minecraft");
|
||||||
Set<ModelResourceLocation> ourModelLocations;
|
Set<ModelResourceLocation> ourModelLocations;
|
||||||
if (config == UniverseVisibility.SELF_AND_DEPS) {
|
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()));
|
ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.id().getNamespace()));
|
||||||
} else {
|
} else {
|
||||||
ourModelLocations = this.topLevelModelLocations;
|
ourModelLocations = this.topLevelModelLocations;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user