Skip to content

Commit

Permalink
#599 Fixed multiworld references to unloaded worlds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Jul 28, 2024
1 parent eabfdc0 commit a3a2911
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 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 = "9.11.0"
version = "9.11.1"

repositories {
mavenCentral()
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,17 @@ class PetEntityImpl(

this.petMeta.lastStoredLocation = physicsComponent.position.copy()
this.velocity = physicsComponent.motion.copy()
physicsComponent.tickMinecraft()

try {
physicsComponent.tickMinecraft()
} catch (e: Exception) {
// Can happen if an invalid world reference exists. e.g. pet references unloaded world
this.petMeta.lastStoredLocation = pet.player.location.toVector3d()
this.physicsComponent.position = pet.player.location.toVector3d()
this.pet.call()
return
}

playerComponent.tickMinecraft()
entityComponent.tickMinecraft()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ class PetListener @Inject constructor(
)
}
}

// Fix references of pet to world which does not exist anymore. e.g. Cross Servers
for (pet in pets) {
var resetToOwnerPosition = false

try {
if (pet.location.world == null) {
resetToOwnerPosition = true
}
} catch (e: Exception) {
// Exception handling is important here.
resetToOwnerPosition = true
}

if (resetToOwnerPosition) {
pet.location = player.location
}
}
}
}

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: PetBlocks
version: 9.11.0
version: 9.11.1
author: Shynixn
main: com.github.shynixn.petblocks.PetBlocksPlugin
softdepend: [ PlaceholderAPI, HeadDatabase]
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: PetBlocks
version: 9.11.0
version: 9.11.1
author: Shynixn
main: com.github.shynixn.petblocks.PetBlocksPlugin
softdepend: [ PlaceholderAPI, HeadDatabase]
Expand Down

0 comments on commit a3a2911

Please sign in to comment.