/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.client.renderer.chunk; import net.minecraft.client.renderer.chunk.SectionCopy; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.SectionPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.ColorResolver; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import org.jspecify.annotations.Nullable; public class RenderSectionRegion implements BlockAndTintGetter { public static final int RADIUS = 1; public static final int SIZE = 3; private final int minSectionX; private final int minSectionY; private final int minSectionZ; private final SectionCopy[] sections; private final Level level; RenderSectionRegion(Level level, int minSectionX, int minSectionY, int minSectionZ, SectionCopy[] sections) { this.level = level; this.minSectionX = minSectionX; this.minSectionY = minSectionY; this.minSectionZ = minSectionZ; this.sections = sections; } @Override public BlockState getBlockState(BlockPos pos) { return this.getSection(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); } @Override public FluidState getFluidState(BlockPos pos) { return this.getSection(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos).getFluidState(); } @Override public float getShade(Direction direction, boolean shade) { return this.level.getShade(direction, shade); } @Override public LevelLightEngine getLightEngine() { return this.level.getLightEngine(); } @Override public @Nullable BlockEntity getBlockEntity(BlockPos pos) { return this.getSection(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockEntity(pos); } private SectionCopy getSection(int sectionX, int sectionY, int sectionZ) { return this.sections[RenderSectionRegion.index(this.minSectionX, this.minSectionY, this.minSectionZ, sectionX, sectionY, sectionZ)]; } @Override public int getBlockTint(BlockPos pos, ColorResolver resolver) { return this.level.getBlockTint(pos, resolver); } @Override public int getMinY() { return this.level.getMinY(); } @Override public int getHeight() { return this.level.getHeight(); } public static int index(int minSectionX, int minSectionY, int minSectionZ, int sectionX, int sectionY, int sectionZ) { return sectionX - minSectionX + (sectionY - minSectionY) * 3 + (sectionZ - minSectionZ) * 3 * 3; } }