Public Access
This commit is contained in:
1 parent
1586597161
commit
ee388f2b55
6 files changed
+55
-17
No files matched your search
+1
-1
@@ -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.
|
# 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
|
mod_license=LGPL-3.0-or-later
|
||||||
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
||||||
mod_version=0.2.16.9
|
mod_version=0.2.16.10
|
||||||
immersive_portals_version=6.0.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.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ public final class LinkingService {
|
|||||||
return travel(player, target, false);
|
return travel(player, target, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<Vec3> resolveDestination(ServerLevel level, BlockPos origin, boolean ageArrival) {
|
||||||
|
return ageArrival
|
||||||
|
? findFootedAgeDestination(level, origin)
|
||||||
|
: findSafeDestination(level, origin, false);
|
||||||
|
}
|
||||||
|
|
||||||
/** Travels to an Age-style destination, which must have solid footing. */
|
/** Travels to an Age-style destination, which must have solid footing. */
|
||||||
public static LinkResult travelWithFooting(ServerPlayer player, LinkTarget target) {
|
public static LinkResult travelWithFooting(ServerPlayer player, LinkTarget target) {
|
||||||
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
||||||
@@ -35,7 +41,7 @@ public final class LinkingService {
|
|||||||
return LinkResult.MISSING_DIMENSION;
|
return LinkResult.MISSING_DIMENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Vec3> destination = findFootedAgeDestination(destinationLevel, target.location().pos());
|
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), true);
|
||||||
if (destination.isEmpty()) {
|
if (destination.isEmpty()) {
|
||||||
return LinkResult.NO_SAFE_DESTINATION;
|
return LinkResult.NO_SAFE_DESTINATION;
|
||||||
}
|
}
|
||||||
@@ -52,7 +58,7 @@ public final class LinkingService {
|
|||||||
return LinkResult.MISSING_DIMENSION;
|
return LinkResult.MISSING_DIMENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Vec3> destination = findSafeDestination(destinationLevel, target.location().pos(), requiresFooting);
|
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), requiresFooting);
|
||||||
if (destination.isEmpty()) {
|
if (destination.isEmpty()) {
|
||||||
return LinkResult.NO_SAFE_DESTINATION;
|
return LinkResult.NO_SAFE_DESTINATION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.mojang.blaze3d.platform.InputConstants;
|
|||||||
import net.dnorberg.rivencraft.client.screen.ExplorableBookScreen;
|
import net.dnorberg.rivencraft.client.screen.ExplorableBookScreen;
|
||||||
import net.dnorberg.rivencraft.network.LinkPreviewPayload;
|
import net.dnorberg.rivencraft.network.LinkPreviewPayload;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.KeyMapping;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||||
import net.neoforged.neoforge.client.event.InputEvent;
|
import net.neoforged.neoforge.client.event.InputEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderGuiEvent;
|
import net.neoforged.neoforge.client.event.RenderGuiEvent;
|
||||||
@@ -11,12 +13,15 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
|
|
||||||
public final class ClientBookExploreOverlay {
|
public final class ClientBookExploreOverlay {
|
||||||
private static ExplorableBookScreen bookScreen;
|
private static ExplorableBookScreen bookScreen;
|
||||||
|
private static Vec3 playerPosition;
|
||||||
|
|
||||||
private ClientBookExploreOverlay() {
|
private ClientBookExploreOverlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void open(ExplorableBookScreen screen) {
|
public static void open(ExplorableBookScreen screen) {
|
||||||
bookScreen = screen;
|
bookScreen = screen;
|
||||||
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
|
playerPosition = minecraft.player == null ? null : minecraft.player.position();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean acceptPreview(LinkPreviewPayload payload) {
|
public static boolean acceptPreview(LinkPreviewPayload payload) {
|
||||||
@@ -27,7 +32,27 @@ public final class ClientBookExploreOverlay {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onClientTick(ClientTickEvent.Post event) {
|
public static void onClientTickPre(ClientTickEvent.Pre event) {
|
||||||
|
if (bookScreen == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
|
if (minecraft.player != null) {
|
||||||
|
minecraft.options.keyUp.setDown(false);
|
||||||
|
minecraft.options.keyDown.setDown(false);
|
||||||
|
minecraft.options.keyLeft.setDown(false);
|
||||||
|
minecraft.options.keyRight.setDown(false);
|
||||||
|
minecraft.options.keyJump.setDown(false);
|
||||||
|
minecraft.options.keyShift.setDown(false);
|
||||||
|
minecraft.options.keySprint.setDown(false);
|
||||||
|
minecraft.player.input.forwardImpulse = 0.0F;
|
||||||
|
minecraft.player.input.leftImpulse = 0.0F;
|
||||||
|
minecraft.player.input.jumping = false;
|
||||||
|
minecraft.player.input.shiftKeyDown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onClientTickPost(ClientTickEvent.Post event) {
|
||||||
if (bookScreen == null) {
|
if (bookScreen == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -35,8 +60,13 @@ public final class ClientBookExploreOverlay {
|
|||||||
if (minecraft.player == null || minecraft.level == null) {
|
if (minecraft.player == null || minecraft.level == null) {
|
||||||
bookScreen.abandonExploreOverlay();
|
bookScreen.abandonExploreOverlay();
|
||||||
bookScreen = null;
|
bookScreen = null;
|
||||||
|
playerPosition = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (playerPosition != null) {
|
||||||
|
minecraft.player.setPos(playerPosition);
|
||||||
|
minecraft.player.setDeltaMovement(Vec3.ZERO);
|
||||||
|
}
|
||||||
bookScreen.tickExploreOverlay();
|
bookScreen.tickExploreOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +87,8 @@ public final class ClientBookExploreOverlay {
|
|||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
ExplorableBookScreen screen = bookScreen;
|
ExplorableBookScreen screen = bookScreen;
|
||||||
bookScreen = null;
|
bookScreen = null;
|
||||||
|
playerPosition = null;
|
||||||
|
KeyMapping.setAll();
|
||||||
screen.returnFromExploreOverlay();
|
screen.returnFromExploreOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,8 @@ public final class ClientEvents {
|
|||||||
public static void clientSetup(FMLClientSetupEvent event) {
|
public static void clientSetup(FMLClientSetupEvent event) {
|
||||||
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickItem);
|
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickItem);
|
||||||
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickBlock);
|
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickBlock);
|
||||||
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onClientTick);
|
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onClientTickPre);
|
||||||
|
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onClientTickPost);
|
||||||
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onRenderGui);
|
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onRenderGui);
|
||||||
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onMouseButton);
|
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onMouseButton);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-11
@@ -24,8 +24,6 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
|||||||
private final Minecraft minecraft = Minecraft.getInstance();
|
private final Minecraft minecraft = Minecraft.getInstance();
|
||||||
private LinkPreviewPayload destination;
|
private LinkPreviewPayload destination;
|
||||||
private Vec3 cameraPosition;
|
private Vec3 cameraPosition;
|
||||||
private Vec3 explorationPlayerOrigin;
|
|
||||||
private Vec3 explorationCameraOrigin;
|
|
||||||
private float explorationPlayerYaw;
|
private float explorationPlayerYaw;
|
||||||
private float explorationPlayerPitch;
|
private float explorationPlayerPitch;
|
||||||
private float explorationCameraYaw;
|
private float explorationCameraYaw;
|
||||||
@@ -54,8 +52,7 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
|||||||
if (!exploring || cameraPosition == null) {
|
if (!exploring || cameraPosition == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (minecraft.player != null && explorationPlayerOrigin != null && explorationCameraOrigin != null) {
|
if (minecraft.player != null) {
|
||||||
cameraPosition = explorationCameraOrigin.add(minecraft.player.position().subtract(explorationPlayerOrigin));
|
|
||||||
yaw = explorationCameraYaw + Mth.wrapDegrees(minecraft.player.getYRot() - explorationPlayerYaw);
|
yaw = explorationCameraYaw + Mth.wrapDegrees(minecraft.player.getYRot() - explorationPlayerYaw);
|
||||||
pitch = Mth.clamp(explorationCameraPitch
|
pitch = Mth.clamp(explorationCameraPitch
|
||||||
+ minecraft.player.getXRot() - explorationPlayerPitch, -89.0F, 89.0F);
|
+ minecraft.player.getXRot() - explorationPlayerPitch, -89.0F, 89.0F);
|
||||||
@@ -131,17 +128,17 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
|||||||
@Override
|
@Override
|
||||||
public void setExploring(boolean exploring) {
|
public void setExploring(boolean exploring) {
|
||||||
this.exploring = exploring;
|
this.exploring = exploring;
|
||||||
if (exploring && minecraft.player != null) {
|
if (exploring && minecraft.player != null && destination != null) {
|
||||||
explorationPlayerOrigin = minecraft.player.position();
|
cameraPosition = Vec3.atBottomCenterOf(destination.origin())
|
||||||
explorationCameraOrigin = cameraPosition;
|
.add(0.0D, minecraft.player.getEyeHeight(), 0.0D);
|
||||||
|
yaw = destination.yaw();
|
||||||
|
pitch = destination.pitch();
|
||||||
explorationPlayerYaw = minecraft.player.getYRot();
|
explorationPlayerYaw = minecraft.player.getYRot();
|
||||||
explorationPlayerPitch = minecraft.player.getXRot();
|
explorationPlayerPitch = minecraft.player.getXRot();
|
||||||
explorationCameraYaw = yaw;
|
explorationCameraYaw = yaw;
|
||||||
explorationCameraPitch = pitch;
|
explorationCameraPitch = pitch;
|
||||||
} else {
|
} else {
|
||||||
clearMovement();
|
clearMovement();
|
||||||
explorationPlayerOrigin = null;
|
|
||||||
explorationCameraOrigin = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +223,6 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
|||||||
public void resetView() {
|
public void resetView() {
|
||||||
exploring = false;
|
exploring = false;
|
||||||
clearMovement();
|
clearMovement();
|
||||||
explorationPlayerOrigin = null;
|
|
||||||
explorationCameraOrigin = null;
|
|
||||||
if (destination != null) {
|
if (destination != null) {
|
||||||
cameraPosition = Vec3.atCenterOf(destination.origin()).add(0.0D, 2.0D, ORBIT_RADIUS);
|
cameraPosition = Vec3.atCenterOf(destination.origin()).add(0.0D, 2.0D, ORBIT_RADIUS);
|
||||||
yaw = destination.yaw();
|
yaw = destination.yaw();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.dnorberg.rivencraft.network;
|
package net.dnorberg.rivencraft.network;
|
||||||
|
|
||||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkingService;
|
||||||
import net.dnorberg.rivencraft.book.AgeReference;
|
import net.dnorberg.rivencraft.book.AgeReference;
|
||||||
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||||
@@ -224,7 +225,10 @@ public final class ModNetworking {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos origin = target.location().pos();
|
BlockPos origin = LinkingService.resolveDestination(
|
||||||
|
level, target.location().pos(), payload.descriptiveBook())
|
||||||
|
.map(BlockPos::containing)
|
||||||
|
.orElse(target.location().pos());
|
||||||
List<LinkPreviewPayload.SnapshotBlock> blocks = new ArrayList<>();
|
List<LinkPreviewPayload.SnapshotBlock> blocks = new ArrayList<>();
|
||||||
// The cubic footprint survives every angle of the orbit. The target is
|
// The cubic footprint survives every angle of the orbit. The target is
|
||||||
// kept at the preview camera's current center point.
|
// kept at the preview camera's current center point.
|
||||||
|
|||||||
Reference in new issue
Block a user