Public Access
This commit is contained in:
1 parent
0ff6036fcc
commit
3232051ad4
6 files changed
+30
-12
No files matched your search
+9
-2
@@ -43,7 +43,12 @@ public final class PonderDestinationPreviewRenderer implements DestinationPrevie
|
||||
public PonderDestinationPreviewRenderer() {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
previewLevel = new PonderLevel(BlockPos.ZERO, minecraft.level);
|
||||
snapshotSelection = SelectionImpl.of(new BoundingBox(0, 0, 0, 8, 63, 8));
|
||||
snapshotSelection = SelectionImpl.of(new BoundingBox(
|
||||
0, 0, 0,
|
||||
LinkPreviewPayload.SNAPSHOT_SIZE - 1,
|
||||
LinkPreviewPayload.SNAPSHOT_SIZE - 1,
|
||||
LinkPreviewPayload.SNAPSHOT_SIZE - 1
|
||||
));
|
||||
// Keep the target-centered 9×7×9 camera framing below, but give Ponder
|
||||
// the entire snapshot so terrain above and below that window is still
|
||||
// part of the rotating scene.
|
||||
@@ -109,7 +114,9 @@ public final class PonderDestinationPreviewRenderer implements DestinationPrevie
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees((ticks + partialTick) * 0.6F));
|
||||
UIRenderHelper.flipForGuiRender(poseStack);
|
||||
poseStack.scale(7.0F, 7.0F, 7.0F);
|
||||
poseStack.translate(-4.5F, -31.5F, -4.5F);
|
||||
// The target moves from (4, 32, 4) to (9, 9, 9) in the cubic
|
||||
// snapshot, so retain its existing camera position relative to it.
|
||||
poseStack.translate(-9.5F, -8.5F, -9.5F);
|
||||
|
||||
SuperRenderTypeBuffer buffer = DefaultSuperRenderTypeBuffer.getInstance();
|
||||
section.renderFirst(previewLevel, buffer, graphics, partialTick);
|
||||
|
||||
@@ -12,8 +12,10 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public record LinkPreviewPayload(int skyColor, List<SnapshotBlock> blocks) implements CustomPacketPayload {
|
||||
/** A square footprint keeps every side visible during an orbit, with a vertical snapshot cache. */
|
||||
private static final int MAX_BLOCKS = 9 * 64 * 9;
|
||||
/** Each axis of the destination volume captured for the book preview. */
|
||||
public static final int SNAPSHOT_SIZE = 18;
|
||||
/** A square footprint keeps every side visible during an orbit. */
|
||||
private static final int MAX_BLOCKS = SNAPSHOT_SIZE * SNAPSHOT_SIZE * SNAPSHOT_SIZE;
|
||||
public static final Type<LinkPreviewPayload> TYPE = new Type<>(
|
||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "link_preview")
|
||||
);
|
||||
|
||||
@@ -114,12 +114,17 @@ public final class ModNetworking {
|
||||
|
||||
BlockPos origin = target.location().pos();
|
||||
List<LinkPreviewPayload.SnapshotBlock> blocks = new ArrayList<>();
|
||||
// The square footprint survives every angle of the orbit. Retain a
|
||||
// 64-block vertical slice, while the renderer shows its 7-block window.
|
||||
for (BlockPos pos : BlockPos.betweenClosed(origin.offset(-4, -32, -4), origin.offset(4, 31, 4))) {
|
||||
// The cubic footprint survives every angle of the orbit. The target is
|
||||
// kept at the preview camera's current center point.
|
||||
int negativeRadius = LinkPreviewPayload.SNAPSHOT_SIZE / 2;
|
||||
int positiveRadius = negativeRadius - 1;
|
||||
for (BlockPos pos : BlockPos.betweenClosed(
|
||||
origin.offset(-negativeRadius, -negativeRadius, -negativeRadius),
|
||||
origin.offset(positiveRadius, positiveRadius, positiveRadius))) {
|
||||
var state = level.getBlockState(pos);
|
||||
if (!state.isAir()) {
|
||||
blocks.add(new LinkPreviewPayload.SnapshotBlock(pos.subtract(origin).offset(4, 32, 4), state));
|
||||
blocks.add(new LinkPreviewPayload.SnapshotBlock(
|
||||
pos.subtract(origin).offset(negativeRadius, negativeRadius, negativeRadius), state));
|
||||
}
|
||||
}
|
||||
int skyColor = level.getBiome(origin).value().getSkyColor();
|
||||
|
||||
Reference in new issue
Block a user