/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.common.collect.Lists * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.datafixers.util.Either * com.mojang.serialization.Codec * com.mojang.serialization.DataResult * com.mojang.serialization.codecs.RecordCodecBuilder * it.unimi.dsi.fastutil.objects.ObjectArrayList */ package net.minecraft.client.renderer.block.model; import com.google.common.collect.Lists; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.lang.runtime.SwitchBootstraps; import java.util.ArrayList; import java.util.List; import java.util.Objects; import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.renderer.block.model.SingleVariant; import net.minecraft.client.renderer.block.model.Variant; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ResolvableModel; import net.minecraft.client.resources.model.WeightedVariants; import net.minecraft.util.ExtraCodecs; import net.minecraft.util.RandomSource; import net.minecraft.util.random.Weighted; import net.minecraft.util.random.WeightedList; import net.minecraft.world.level.block.state.BlockState; public interface BlockStateModel { public void collectParts(RandomSource var1, List var2); default public List collectParts(RandomSource random) { ObjectArrayList parts = new ObjectArrayList(); this.collectParts(random, (List)parts); return parts; } public TextureAtlasSprite particleIcon(); public static class SimpleCachedUnbakedRoot implements UnbakedRoot { private final Unbaked contents; private final ModelBaker.SharedOperationKey bakingKey = new ModelBaker.SharedOperationKey(){ @Override public BlockStateModel compute(ModelBaker modelBakery) { return contents.bake(modelBakery); } }; public SimpleCachedUnbakedRoot(Unbaked contents) { this.contents = contents; } @Override public void resolveDependencies(ResolvableModel.Resolver resolver) { this.contents.resolveDependencies(resolver); } @Override public BlockStateModel bake(BlockState blockState, ModelBaker modelBakery) { return modelBakery.compute(this.bakingKey); } @Override public Object visualEqualityGroup(BlockState blockState) { return this; } } public static interface Unbaked extends ResolvableModel { public static final Codec> ELEMENT_CODEC = RecordCodecBuilder.create(i -> i.group((App)Variant.MAP_CODEC.forGetter(Weighted::value), (App)ExtraCodecs.POSITIVE_INT.optionalFieldOf("weight", (Object)1).forGetter(Weighted::weight)).apply((Applicative)i, Weighted::new)); public static final Codec HARDCODED_WEIGHTED_CODEC = ExtraCodecs.nonEmptyList(ELEMENT_CODEC.listOf()).flatComapMap(w -> new WeightedVariants.Unbaked(WeightedList.of(Lists.transform((List)w, e -> e.map(SingleVariant.Unbaked::new)))), unbaked -> { List> entries = unbaked.entries().unwrap(); ArrayList> result = new ArrayList>(entries.size()); for (Weighted entry : entries) { Unbaked patt0$temp = entry.value(); if (patt0$temp instanceof SingleVariant.Unbaked) { SingleVariant.Unbaked singleVariant = (SingleVariant.Unbaked)patt0$temp; result.add(new Weighted(singleVariant.variant(), entry.weight())); continue; } return DataResult.error(() -> "Only single variants are supported"); } return DataResult.success(result); }); public static final Codec CODEC = Codec.either(HARDCODED_WEIGHTED_CODEC, SingleVariant.Unbaked.CODEC).flatComapMap(v -> (Unbaked)v.map(l -> l, r -> r), o -> { Unbaked unbaked = o; Objects.requireNonNull(unbaked); Unbaked selector0$temp = unbaked; int index$1 = 0; return switch (SwitchBootstraps.typeSwitch("typeSwitch", new Object[]{SingleVariant.Unbaked.class, WeightedVariants.Unbaked.class}, (Object)selector0$temp, index$1)) { case 0 -> { SingleVariant.Unbaked single = (SingleVariant.Unbaked)selector0$temp; yield DataResult.success((Object)Either.right((Object)single)); } case 1 -> { WeightedVariants.Unbaked multiple = (WeightedVariants.Unbaked)selector0$temp; yield DataResult.success((Object)Either.left((Object)multiple)); } default -> DataResult.error(() -> "Only a single variant or a list of variants are supported"); }; }); public BlockStateModel bake(ModelBaker var1); default public UnbakedRoot asRoot() { return new SimpleCachedUnbakedRoot(this); } } public static interface UnbakedRoot extends ResolvableModel { public BlockStateModel bake(BlockState var1, ModelBaker var2); public Object visualEqualityGroup(BlockState var1); } }