/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.util.Function3 * com.mojang.datafixers.util.Function4 * com.mojang.datafixers.util.Function5 */ package net.minecraft.client.data.models.blockstates; import com.mojang.datafixers.util.Function3; import com.mojang.datafixers.util.Function4; import com.mojang.datafixers.util.Function5; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Stream; import net.minecraft.client.data.models.MultiVariant; import net.minecraft.client.data.models.blockstates.PropertyValueList; import net.minecraft.client.renderer.block.model.VariantMutator; import net.minecraft.world.level.block.state.properties.Property; public abstract class PropertyDispatch { private final Map values = new HashMap(); protected void putValue(PropertyValueList key, V variant) { V previous = this.values.put(key, variant); if (previous != null) { throw new IllegalStateException("Value " + String.valueOf(key) + " is already defined"); } } Map getEntries() { this.verifyComplete(); return Map.copyOf(this.values); } private void verifyComplete() { List> properties = this.getDefinedProperties(); Stream valuesToCover = Stream.of(PropertyValueList.EMPTY); for (Property property : properties) { valuesToCover = valuesToCover.flatMap(current -> property.getAllValues().map(current::extend)); } List undefinedCombinations = valuesToCover.filter(f -> !this.values.containsKey(f)).toList(); if (!undefinedCombinations.isEmpty()) { throw new IllegalStateException("Missing definition for properties: " + String.valueOf(undefinedCombinations)); } } abstract List> getDefinedProperties(); public static > C1 initial(Property property1) { return new C1(property1); } public static , T2 extends Comparable> C2 initial(Property property1, Property property2) { return new C2(property1, property2); } public static , T2 extends Comparable, T3 extends Comparable> C3 initial(Property property1, Property property2, Property property3) { return new C3(property1, property2, property3); } public static , T2 extends Comparable, T3 extends Comparable, T4 extends Comparable> C4 initial(Property property1, Property property2, Property property3, Property property4) { return new C4(property1, property2, property3, property4); } public static , T2 extends Comparable, T3 extends Comparable, T4 extends Comparable, T5 extends Comparable> C5 initial(Property property1, Property property2, Property property3, Property property4, Property property5) { return new C5(property1, property2, property3, property4, property5); } public static > C1 modify(Property property1) { return new C1(property1); } public static , T2 extends Comparable> C2 modify(Property property1, Property property2) { return new C2(property1, property2); } public static , T2 extends Comparable, T3 extends Comparable> C3 modify(Property property1, Property property2, Property property3) { return new C3(property1, property2, property3); } public static , T2 extends Comparable, T3 extends Comparable, T4 extends Comparable> C4 modify(Property property1, Property property2, Property property3, Property property4) { return new C4(property1, property2, property3, property4); } public static , T2 extends Comparable, T3 extends Comparable, T4 extends Comparable, T5 extends Comparable> C5 modify(Property property1, Property property2, Property property3, Property property4, Property property5) { return new C5(property1, property2, property3, property4, property5); } public static class C1> extends PropertyDispatch { private final Property property1; private C1(Property property1) { this.property1 = property1; } @Override public List> getDefinedProperties() { return List.of(this.property1); } public C1 select(T1 value1, V variants) { PropertyValueList key = PropertyValueList.of(this.property1.value(value1)); this.putValue(key, variants); return this; } public PropertyDispatch generate(Function generator) { this.property1.getPossibleValues().forEach(value1 -> this.select(value1, generator.apply(value1))); return this; } } public static class C2, T2 extends Comparable> extends PropertyDispatch { private final Property property1; private final Property property2; private C2(Property property1, Property property2) { this.property1 = property1; this.property2 = property2; } @Override public List> getDefinedProperties() { return List.of(this.property1, this.property2); } public C2 select(T1 value1, T2 value2, V variants) { PropertyValueList key = PropertyValueList.of(this.property1.value(value1), this.property2.value(value2)); this.putValue(key, variants); return this; } public PropertyDispatch generate(BiFunction generator) { this.property1.getPossibleValues().forEach(value1 -> this.property2.getPossibleValues().forEach(value2 -> this.select(value1, value2, generator.apply(value1, value2)))); return this; } } public static class C3, T2 extends Comparable, T3 extends Comparable> extends PropertyDispatch { private final Property property1; private final Property property2; private final Property property3; private C3(Property property1, Property property2, Property property3) { this.property1 = property1; this.property2 = property2; this.property3 = property3; } @Override public List> getDefinedProperties() { return List.of(this.property1, this.property2, this.property3); } public C3 select(T1 value1, T2 value2, T3 value3, V variants) { PropertyValueList key = PropertyValueList.of(this.property1.value(value1), this.property2.value(value2), this.property3.value(value3)); this.putValue(key, variants); return this; } public PropertyDispatch generate(Function3 generator) { this.property1.getPossibleValues().forEach(value1 -> this.property2.getPossibleValues().forEach(value2 -> this.property3.getPossibleValues().forEach(value3 -> this.select(value1, value2, value3, generator.apply(value1, value2, value3))))); return this; } } public static class C4, T2 extends Comparable, T3 extends Comparable, T4 extends Comparable> extends PropertyDispatch { private final Property property1; private final Property property2; private final Property property3; private final Property property4; private C4(Property property1, Property property2, Property property3, Property property4) { this.property1 = property1; this.property2 = property2; this.property3 = property3; this.property4 = property4; } @Override public List> getDefinedProperties() { return List.of(this.property1, this.property2, this.property3, this.property4); } public C4 select(T1 value1, T2 value2, T3 value3, T4 value4, V variants) { PropertyValueList key = PropertyValueList.of(this.property1.value(value1), this.property2.value(value2), this.property3.value(value3), this.property4.value(value4)); this.putValue(key, variants); return this; } public PropertyDispatch generate(Function4 generator) { this.property1.getPossibleValues().forEach(value1 -> this.property2.getPossibleValues().forEach(value2 -> this.property3.getPossibleValues().forEach(value3 -> this.property4.getPossibleValues().forEach(value4 -> this.select(value1, value2, value3, value4, generator.apply(value1, value2, value3, value4)))))); return this; } } public static class C5, T2 extends Comparable, T3 extends Comparable, T4 extends Comparable, T5 extends Comparable> extends PropertyDispatch { private final Property property1; private final Property property2; private final Property property3; private final Property property4; private final Property property5; private C5(Property property1, Property property2, Property property3, Property property4, Property property5) { this.property1 = property1; this.property2 = property2; this.property3 = property3; this.property4 = property4; this.property5 = property5; } @Override public List> getDefinedProperties() { return List.of(this.property1, this.property2, this.property3, this.property4, this.property5); } public C5 select(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, V variants) { PropertyValueList key = PropertyValueList.of(this.property1.value(value1), this.property2.value(value2), this.property3.value(value3), this.property4.value(value4), this.property5.value(value5)); this.putValue(key, variants); return this; } public PropertyDispatch generate(Function5 generator) { this.property1.getPossibleValues().forEach(value1 -> this.property2.getPossibleValues().forEach(value2 -> this.property3.getPossibleValues().forEach(value3 -> this.property4.getPossibleValues().forEach(value4 -> this.property5.getPossibleValues().forEach(value5 -> this.select(value1, value2, value3, value4, value5, generator.apply(value1, value2, value3, value4, value5))))))); return this; } } }