/* * Decompiled with CFR 0.152. */ package net.minecraft.client.renderer.entity; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.state.FallingBlockRenderState; import net.minecraft.client.renderer.state.CameraRenderState; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.state.BlockState; public class FallingBlockRenderer extends EntityRenderer { public FallingBlockRenderer(EntityRendererProvider.Context context) { super(context); this.shadowRadius = 0.5f; } @Override public boolean shouldRender(FallingBlockEntity entity, Frustum culler, double camX, double camY, double camZ) { if (!super.shouldRender(entity, culler, camX, camY, camZ)) { return false; } return entity.getBlockState() != entity.level().getBlockState(entity.blockPosition()); } @Override public void submit(FallingBlockRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) { BlockState blockState = state.movingBlockRenderState.blockState; if (blockState.getRenderShape() != RenderShape.MODEL) { return; } poseStack.pushPose(); poseStack.translate(-0.5, 0.0, -0.5); submitNodeCollector.submitMovingBlock(poseStack, state.movingBlockRenderState); poseStack.popPose(); super.submit(state, poseStack, submitNodeCollector, camera); } @Override public FallingBlockRenderState createRenderState() { return new FallingBlockRenderState(); } @Override public void extractRenderState(FallingBlockEntity entity, FallingBlockRenderState state, float partialTicks) { super.extractRenderState(entity, state, partialTicks); BlockPos pos = BlockPos.containing(entity.getX(), entity.getBoundingBox().maxY, entity.getZ()); state.movingBlockRenderState.randomSeedPos = entity.getStartPos(); state.movingBlockRenderState.blockPos = pos; state.movingBlockRenderState.blockState = entity.getBlockState(); state.movingBlockRenderState.biome = entity.level().getBiome(pos); state.movingBlockRenderState.level = entity.level(); } }