From dd8d10c64488920772f02b4679c92dbf43287a27 Mon Sep 17 00:00:00 2001 From: Leclowndu93150 Date: Fri, 15 May 2026 20:37:21 +0200 Subject: [PATCH 1/2] movement fix --- .../walkways/WalkwayMovementHandler.java | 83 +++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/src/main/java/rbasamoyai/escalated/walkways/WalkwayMovementHandler.java b/src/main/java/rbasamoyai/escalated/walkways/WalkwayMovementHandler.java index 14e8aff..45a7510 100644 --- a/src/main/java/rbasamoyai/escalated/walkways/WalkwayMovementHandler.java +++ b/src/main/java/rbasamoyai/escalated/walkways/WalkwayMovementHandler.java @@ -152,14 +152,18 @@ public static void transportEntity(WalkwayBlockEntity walkwayBE, Entity entity, entity.fallDistance = 0; + if (isPlayer && hasMovementInput(entity) && (movingUp || movingDown)) { + applyPlayerInputCombinedMovement(entity, transformMovement(movement, walkwayBE), movingUp, movingDown, movementSpeed); + if (!entity.level().isClientSide) + WalkwayTravelTracker.trackPlayerOnWalkway((Player) entity, 300); // 15 seconds + return; + } + if (movingUp) { - Vec3 prevPos = entity.position(); - entity.move(SELF, transformMovement(movement, walkwayBE)); - if (entity.horizontalCollision) { - entity.setPos(prevPos); // Restore position and try again, but with adjusted starting condition - entity.move(SELF, transformMovement(new Vec3(0, movement.y * 0.1, 0), walkwayBE)); // adjusted - entity.move(SELF, transformMovement(movement, walkwayBE)); - } + float minVelocity = .13f; + float yMovement = (float) -Math.max(Math.abs(movement.y), minVelocity); + entity.move(SELF, transformMovement(new Vec3(0, yMovement, 0), walkwayBE)); + entity.move(SELF, transformMovement(movement.multiply(1, 0, 1), walkwayBE)); } else if (movingDown) { entity.move(SELF, transformMovement(movement.multiply(1, 0, 1), walkwayBE)); entity.move(SELF, transformMovement(movement.multiply(0, 1, 0), walkwayBE)); @@ -176,6 +180,71 @@ public static void transportEntity(WalkwayBlockEntity walkwayBE, Entity entity, if (!isPlayer && entity instanceof LivingEntity livingEntity) { livingEntity.getAttribute(Attributes.STEP_HEIGHT).setBaseValue(step); } + + boolean movedPastEndingSlope = onSlope && (isWalkway(level, entity.blockPosition()) || isWalkway(level, entity.blockPosition().below())); + + if (movedPastEndingSlope && !movingDown && Math.abs(movementSpeed) > 0) + entity.setPos(entity.getX(), entity.getY() + movement.y, entity.getZ()); + if (movedPastEndingSlope) { + entity.setDeltaMovement(transformMovement(movement, walkwayBE)); + entity.hurtMarked = true; + } + } + + private static boolean isWalkway(Level level, BlockPos pos) { + return level.getBlockState(pos).getBlock() instanceof WalkwayBlock; + } + + private static boolean hasMovementInput(Entity entity) { + return entity instanceof LivingEntity living && (living.zza != 0 || living.xxa != 0); + } + + private static void applyPlayerInputCombinedMovement(Entity entity, Vec3 movement, boolean movingUp, boolean movingDown, float movementSpeed) { + Vec3 delta = entity.getDeltaMovement(); + Vec3 horizontalAssist = movement.multiply(1, 0, 1); + Vec3 input = getWorldInput(entity); + double dot = input.lengthSqr() < 1.0E-7 || horizontalAssist.lengthSqr() < 1.0E-7 + ? 0 + : input.normalize().dot(horizontalAssist.normalize()); + double scale = dot > 0.25 ? 0.2 : dot < -0.25 ? 0.55 : 0.35; + Vec3 combined = delta; + if (horizontalAssist.lengthSqr() > 1.0E-7) { + Vec3 assistDirection = horizontalAssist.normalize(); + double targetAlongAssist = horizontalAssist.length() * scale; + double currentAlongAssist = delta.dot(assistDirection); + double addAlongAssist = targetAlongAssist - currentAlongAssist; + addAlongAssist = Math.max(-targetAlongAssist, Math.min(targetAlongAssist, addAlongAssist)); + combined = combined.add(assistDirection.scale(addAlongAssist)); + } + + double verticalAssist = Math.min(Math.max(Math.abs(movement.y) * 0.75, Math.abs(movementSpeed) * 0.5), 0.12); + if (movingUp) + combined = new Vec3(combined.x, Math.max(delta.y, verticalAssist), combined.z); + if (movingDown) + combined = new Vec3(combined.x, Math.min(delta.y, -verticalAssist), combined.z); + + entity.setDeltaMovement(combined); + entity.setOnGround(true); + entity.hurtMarked = true; + } + + private static Vec3 getWorldInput(Entity entity) { + if (!(entity instanceof LivingEntity living)) + return Vec3.ZERO; + double x = living.xxa; + double z = living.zza; + double lengthSqr = x * x + z * z; + if (lengthSqr < 1.0E-7) + return Vec3.ZERO; + if (lengthSqr > 1) { + double length = Math.sqrt(lengthSqr); + x /= length; + z /= length; + } + double yaw = Math.toRadians(entity.getYRot()); + double sin = Math.sin(yaw); + double cos = Math.cos(yaw); + return new Vec3(x * cos - z * sin, 0, z * cos + x * sin); } public static boolean shouldIgnoreBlocking(Entity me, Entity other) { From 746de6213ce95ccbe3441009ce6c7657acc302e7 Mon Sep 17 00:00:00 2001 From: Leclowndu93150 Date: Fri, 15 May 2026 20:38:21 +0200 Subject: [PATCH 2/2] movement fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1ef8d0..d5509b9 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,4 @@ This mod adds a few things: An rbasamoyai mod. -Icon by LopyLuna. \ No newline at end of file +Icon by LopyLuna.