2025-11-24 22:52:51 +03:00

72 lines
2.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.kinds.App
* com.mojang.datafixers.kinds.Applicative
* com.mojang.serialization.MapCodec
* com.mojang.serialization.codecs.RecordCodecBuilder
* org.joml.Vector3f
* org.jspecify.annotations.Nullable
*/
package net.minecraft.client.renderer.special;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.datafixers.kinds.App;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.Objects;
import java.util.Set;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.blockentity.BannerRenderer;
import net.minecraft.client.renderer.special.SpecialModelRenderer;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BannerPatternLayers;
import org.joml.Vector3f;
import org.jspecify.annotations.Nullable;
public class BannerSpecialRenderer
implements SpecialModelRenderer<BannerPatternLayers> {
private final BannerRenderer bannerRenderer;
private final DyeColor baseColor;
public BannerSpecialRenderer(DyeColor baseColor, BannerRenderer bannerRenderer) {
this.bannerRenderer = bannerRenderer;
this.baseColor = baseColor;
}
@Override
public @Nullable BannerPatternLayers extractArgument(ItemStack stack) {
return stack.get(DataComponents.BANNER_PATTERNS);
}
@Override
public void submit(@Nullable BannerPatternLayers patterns, ItemDisplayContext type, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, boolean hasFoil, int outlineColor) {
this.bannerRenderer.submitSpecial(poseStack, submitNodeCollector, lightCoords, overlayCoords, this.baseColor, Objects.requireNonNullElse(patterns, BannerPatternLayers.EMPTY), outlineColor);
}
@Override
public void getExtents(Set<Vector3f> result) {
this.bannerRenderer.getExtents(result);
}
public record Unbaked(DyeColor baseColor) implements SpecialModelRenderer.Unbaked
{
public static final MapCodec<Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)DyeColor.CODEC.fieldOf("color").forGetter(Unbaked::baseColor)).apply((Applicative)i, Unbaked::new));
public MapCodec<Unbaked> type() {
return MAP_CODEC;
}
@Override
public SpecialModelRenderer<?> bake(SpecialModelRenderer.BakingContext context) {
return new BannerSpecialRenderer(this.baseColor, new BannerRenderer(context));
}
}
}