Remove leftover files from 1.21.5 feature port
This commit is contained in:
parent
a7e32ad943
commit
b902058cfa
|
|
@ -1,41 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package org.embeddedt.modernfix.neoforge.dynresources;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ModelLocationBuilder {
|
||||
private final Map<Property<?>, PropertyData> propertyToOptionStrings = new Object2ObjectOpenHashMap<>();
|
||||
private final StringBuilder builder = new StringBuilder();
|
||||
|
||||
private record PropertyData(ImmutableList<String> nameValuePairs, int maxPairLength) {}
|
||||
|
||||
public void generateForBlock(Set<ModelResourceLocation> destinationSet, Block block, ResourceLocation baseLocation) {
|
||||
var props = block.getStateDefinition().getProperties();
|
||||
List<ImmutableList<String>> optionsList = new ArrayList<>(props.size());
|
||||
int requiredBuilderSize = Math.max(0, props.size() - 1); // commas
|
||||
for (var prop : props) {
|
||||
var data = propertyToOptionStrings.computeIfAbsent(prop, ModelLocationBuilder::computePropertyOptions);
|
||||
optionsList.add(data.nameValuePairs);
|
||||
requiredBuilderSize += data.maxPairLength;
|
||||
}
|
||||
var product = Lists.cartesianProduct(optionsList);
|
||||
int count = product.size();
|
||||
int tupleEntryCount = optionsList.size();
|
||||
StringBuilder stringbuilder = this.builder;
|
||||
stringbuilder.ensureCapacity(requiredBuilderSize);
|
||||
for (int i = 0; i < count; i++) {
|
||||
stringbuilder.setLength(0);
|
||||
var result = product.get(i);
|
||||
for (int j = 0; j < tupleEntryCount; j++) {
|
||||
if (j != 0) {
|
||||
stringbuilder.append(',');
|
||||
}
|
||||
stringbuilder.append(result.get(j));
|
||||
}
|
||||
destinationSet.add(new ModelResourceLocation(baseLocation, stringbuilder.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static PropertyData computePropertyOptions(Property<?> prop) {
|
||||
ImmutableList.Builder<String> valuesList = ImmutableList.builderWithExpectedSize(prop.getPossibleValues().size());
|
||||
int maxLength = 0;
|
||||
for (var val : prop.getPossibleValues()) {
|
||||
String pair = prop.getName() + "=" + getValueName(prop, val);
|
||||
valuesList.add(pair.toLowerCase(Locale.ROOT));
|
||||
maxLength = Math.max(pair.length(), maxLength);
|
||||
}
|
||||
return new PropertyData(valuesList.build(), maxLength);
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> String getValueName(Property<T> property, Comparable<?> value) {
|
||||
return property.getName((T)value);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user