Skip to content

Commit

Permalink
#519 Fixed length caching for rescue algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Jul 20, 2024
1 parent bbe4987 commit d128071
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.shynixn"
version = "6.46.0"
version = "6.46.1"

repositories {
mavenLocal()
Expand Down Expand Up @@ -42,7 +42,7 @@ dependencies {

// Custom dependencies
implementation("com.github.shynixn.mcutils:common:2024.19")
implementation("com.github.shynixn.mcutils:packet:2024.30")
implementation("com.github.shynixn.mcutils:packet:2024.32")
implementation("com.github.shynixn.mcutils:database:2024.2")
implementation("com.github.shynixn.mcutils:sign:2024.2")
implementation("com.github.shynixn.mcutils:guice:2024.2")
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '6.46.0'
version = '6.46.1'
# The full version, including alpha/beta/rc tags.
release = '6.46.0'
release = '6.46.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import kotlin.math.sin
*/
class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) {
private var stuckCounter = 0
private var cachedLength = 0.5

/**
* Origin coordinate to make relative rotations in the world.
Expand Down Expand Up @@ -200,14 +201,15 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) {
if (rayTraceEvent.hitBlock) {
if (rayTraceEvent.blockDirection == BlockDirection.UP) {
this.stuckCounter = 0
this.cachedLength = this.motion.length()
calculateBallOnGround(players, targetPosition)
return
} else {
stuckCounter++
this.motion = calculateWallBounce(this.motion, rayTraceEvent.blockDirection)
// Fix ball getting stuck in wall by moving back in the direction of its spawnpoint.
if (stuckCounter > 4) {
val velocity = this.spawnpoint.copy().subtract(this.position).normalize().multiply(0.5)
val velocity = this.spawnpoint.copy().subtract(this.position).normalize().multiply(cachedLength)
this.motion = velocity
this.motion.y = 0.1
this.position = this.position.add(this.motion.x, this.motion.y, this.motion.z)
Expand All @@ -220,6 +222,7 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) {
}

this.stuckCounter = 0
this.cachedLength = this.motion.length()
calculateBallOnAir(players, targetPosition)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin-legacy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: BlockBall
version: 6.46.0
version: 6.46.1
author: Shynixn
website: https://www.spigotmc.org/members/shynixn.63455/
main: com.github.shynixn.blockball.BlockBallPlugin
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: BlockBall
version: 6.46.0
version: 6.46.1
author: Shynixn
website: https://www.spigotmc.org/members/shynixn.63455/
main: com.github.shynixn.blockball.BlockBallPlugin
Expand Down

0 comments on commit d128071

Please sign in to comment.