/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.joml.Quaternionfc * org.joml.Vector3f * org.jspecify.annotations.Nullable */ package net.minecraft.client.renderer.blockentity; import com.mojang.blaze3d.vertex.PoseStack; import java.util.Set; import net.minecraft.client.model.Model; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.state.ShulkerBoxRenderState; import net.minecraft.client.renderer.feature.ModelFeatureRenderer; import net.minecraft.client.renderer.rendertype.RenderTypes; import net.minecraft.client.renderer.special.SpecialModelRenderer; import net.minecraft.client.renderer.state.CameraRenderState; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.MaterialSet; import net.minecraft.core.Direction; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.ShulkerBoxBlock; import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; import net.minecraft.world.phys.Vec3; import org.joml.Quaternionfc; import org.joml.Vector3f; import org.jspecify.annotations.Nullable; public class ShulkerBoxRenderer implements BlockEntityRenderer { private final MaterialSet materials; private final ShulkerBoxModel model; public ShulkerBoxRenderer(BlockEntityRendererProvider.Context context) { this(context.entityModelSet(), context.materials()); } public ShulkerBoxRenderer(SpecialModelRenderer.BakingContext context) { this(context.entityModelSet(), context.materials()); } public ShulkerBoxRenderer(EntityModelSet context, MaterialSet materials) { this.materials = materials; this.model = new ShulkerBoxModel(context.bakeLayer(ModelLayers.SHULKER_BOX)); } @Override public ShulkerBoxRenderState createRenderState() { return new ShulkerBoxRenderState(); } @Override public void extractRenderState(ShulkerBoxBlockEntity blockEntity, ShulkerBoxRenderState state, float partialTicks, Vec3 cameraPosition, @Nullable ModelFeatureRenderer.CrumblingOverlay breakProgress) { BlockEntityRenderer.super.extractRenderState(blockEntity, state, partialTicks, cameraPosition, breakProgress); state.direction = blockEntity.getBlockState().getValueOrElse(ShulkerBoxBlock.FACING, Direction.UP); state.color = blockEntity.getColor(); state.progress = blockEntity.getProgress(partialTicks); } @Override public void submit(ShulkerBoxRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) { DyeColor color = state.color; Material material = color == null ? Sheets.DEFAULT_SHULKER_TEXTURE_LOCATION : Sheets.getShulkerBoxMaterial(color); this.submit(poseStack, submitNodeCollector, state.lightCoords, OverlayTexture.NO_OVERLAY, state.direction, state.progress, state.breakProgress, material, 0); } public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, Direction direction, float progress, @Nullable ModelFeatureRenderer.CrumblingOverlay breakProgress, Material material, int outlineColor) { poseStack.pushPose(); this.prepareModel(poseStack, direction, progress); submitNodeCollector.submitModel(this.model, Float.valueOf(progress), poseStack, material.renderType(this.model::renderType), lightCoords, overlayCoords, -1, this.materials.get(material), outlineColor, breakProgress); poseStack.popPose(); } private void prepareModel(PoseStack poseStack, Direction direction, float progress) { poseStack.translate(0.5f, 0.5f, 0.5f); float scale = 0.9995f; poseStack.scale(0.9995f, 0.9995f, 0.9995f); poseStack.mulPose((Quaternionfc)direction.getRotation()); poseStack.scale(1.0f, -1.0f, -1.0f); poseStack.translate(0.0f, -1.0f, 0.0f); this.model.setupAnim(Float.valueOf(progress)); } public void getExtents(Direction direction, float progress, Set result) { PoseStack poseStack = new PoseStack(); this.prepareModel(poseStack, direction, progress); this.model.root().getExtentsForGui(poseStack, result); } private static class ShulkerBoxModel extends Model { private final ModelPart lid; public ShulkerBoxModel(ModelPart root) { super(root, RenderTypes::entityCutoutNoCull); this.lid = root.getChild("lid"); } @Override public void setupAnim(Float progress) { super.setupAnim(progress); this.lid.setPos(0.0f, 24.0f - progress.floatValue() * 0.5f * 16.0f, 0.0f); this.lid.yRot = 270.0f * progress.floatValue() * ((float)Math.PI / 180); } } }