Enable movement in book preview exploration
Build / build (push) Canceled after 0s

This commit is contained in:
dnorberg committed 2026-09-22 05:43:31 -04:00
1 parent 16208c02a4
commit 00ed05e51a
6 files changed
+80 -7

No files matched your search

+5
View File
@@ -301,6 +301,11 @@ Version 0.2.16.6 makes Linking and Descriptive Book screens non-pausing. The
integrated server now continues ticking in single-player while a book is open,
allowing live preview chunks to generate and stream into the snapshot.
Version 0.2.16.7 handles configured movement bindings directly in both book
screens while Explore mode is active. Movement, jump, and sneak now move the
remote camera even though Minecraft suspends normal gameplay key states while
a GUI is open.
The preview code is separated behind a renderer interface and uses an isolated
Ponder level populated from server-authoritative destination snapshots.
+1 -1
View File
@@ -35,7 +35,7 @@ mod_name=Rivencraft
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=LGPL-3.0-or-later
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
mod_version=0.2.16.6
mod_version=0.2.16.7
immersive_portals_version=6.0.7
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
@@ -14,6 +14,8 @@ public interface DestinationPreviewRenderer extends AutoCloseable {
default boolean isExploring() { return false; }
default void setExploring(boolean exploring) { }
default void rotate(double deltaX, double deltaY) { }
default boolean keyPressed(int keyCode, int scanCode) { return false; }
default boolean keyReleased(int keyCode, int scanCode) { return false; }
default void resetView() { }
@Override
@@ -29,6 +29,12 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
private int ticks;
private boolean exploring;
private boolean hasCompletedFrame;
private boolean movingForward;
private boolean movingBackward;
private boolean movingLeft;
private boolean movingRight;
private boolean movingUp;
private boolean movingDown;
@Override
public void accept(LinkPreviewPayload payload) {
@@ -42,12 +48,9 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
if (!exploring || cameraPosition == null) {
return;
}
double forward = (minecraft.options.keyUp.isDown() ? 1.0D : 0.0D)
- (minecraft.options.keyDown.isDown() ? 1.0D : 0.0D);
double strafe = (minecraft.options.keyRight.isDown() ? 1.0D : 0.0D)
- (minecraft.options.keyLeft.isDown() ? 1.0D : 0.0D);
double vertical = (minecraft.options.keyJump.isDown() ? 1.0D : 0.0D)
- (minecraft.options.keyShift.isDown() ? 1.0D : 0.0D);
double forward = (movingForward ? 1.0D : 0.0D) - (movingBackward ? 1.0D : 0.0D);
double strafe = (movingRight ? 1.0D : 0.0D) - (movingLeft ? 1.0D : 0.0D);
double vertical = (movingUp ? 1.0D : 0.0D) - (movingDown ? 1.0D : 0.0D);
double radians = Math.toRadians(yaw);
Vec3 motion = new Vec3(
-Math.sin(radians) * forward + Math.cos(radians) * strafe,
@@ -135,9 +138,47 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
}
}
@Override
public boolean keyPressed(int keyCode, int scanCode) {
if (!exploring) {
return false;
}
if (minecraft.options.keyUp.matches(keyCode, scanCode)) movingForward = true;
else if (minecraft.options.keyDown.matches(keyCode, scanCode)) movingBackward = true;
else if (minecraft.options.keyLeft.matches(keyCode, scanCode)) movingLeft = true;
else if (minecraft.options.keyRight.matches(keyCode, scanCode)) movingRight = true;
else if (minecraft.options.keyJump.matches(keyCode, scanCode)) movingUp = true;
else if (minecraft.options.keyShift.matches(keyCode, scanCode)) movingDown = true;
else return false;
return true;
}
@Override
public boolean keyReleased(int keyCode, int scanCode) {
boolean handled = true;
if (minecraft.options.keyUp.matches(keyCode, scanCode)) movingForward = false;
else if (minecraft.options.keyDown.matches(keyCode, scanCode)) movingBackward = false;
else if (minecraft.options.keyLeft.matches(keyCode, scanCode)) movingLeft = false;
else if (minecraft.options.keyRight.matches(keyCode, scanCode)) movingRight = false;
else if (minecraft.options.keyJump.matches(keyCode, scanCode)) movingUp = false;
else if (minecraft.options.keyShift.matches(keyCode, scanCode)) movingDown = false;
else handled = false;
return handled;
}
private void clearMovement() {
movingForward = false;
movingBackward = false;
movingLeft = false;
movingRight = false;
movingUp = false;
movingDown = false;
}
@Override
public void resetView() {
exploring = false;
clearMovement();
if (destination != null) {
cameraPosition = Vec3.atCenterOf(destination.origin()).add(0.0D, 2.0D, ORBIT_RADIUS);
yaw = destination.yaw();
@@ -147,6 +188,7 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
@Override
public void close() {
clearMovement();
hasCompletedFrame = false;
}
}
@@ -181,6 +181,18 @@ public final class DescriptiveBookScreen extends Screen {
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return preview != null && preview.keyPressed(keyCode, scanCode)
|| super.keyPressed(keyCode, scanCode, modifiers);
}
@Override
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
return preview != null && preview.keyReleased(keyCode, scanCode)
|| super.keyReleased(keyCode, scanCode, modifiers);
}
private void toggleExploration() {
preview.setExploring(!preview.isExploring());
exploreButton.setMessage(Component.translatable(preview.isExploring()
@@ -181,6 +181,18 @@ public final class LinkingBookScreen extends Screen {
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return preview != null && preview.keyPressed(keyCode, scanCode)
|| super.keyPressed(keyCode, scanCode, modifiers);
}
@Override
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
return preview != null && preview.keyReleased(keyCode, scanCode)
|| super.keyReleased(keyCode, scanCode, modifiers);
}
private void toggleExploration() {
preview.setExploring(!preview.isExploring());
exploreButton.setMessage(Component.translatable(preview.isExploring()