Skip to content

Commit

Permalink
#621 Added world transfer guards.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Oct 5, 2024
1 parent c1f4287 commit a7d172a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/github/shynixn/petblocks/impl/PetImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PetImpl(
private var petEntity: PetEntityImpl? = null
private var disposed = false
private var templateCache: PetTemplate? = null
private var isWorldTransferActive : Boolean = false

init {
plugin.launch(plugin.minecraftDispatcher + object : CoroutineTimings() {}) {
Expand Down Expand Up @@ -127,12 +128,14 @@ class PetImpl(
petMeta.lastStoredLocation = value.toVector3d()

if (petEntity != null) {
if (value.world?.name != previousWorld) {
if (value.world?.name != previousWorld && !isWorldTransferActive) {
isWorldTransferActive = true
plugin.launch {
delay(750)
remove()
delay(250)
call()
isWorldTransferActive = false
}
} else {
petEntity?.teleportInWorld(value.toVector3d())
Expand Down

0 comments on commit a7d172a

Please sign in to comment.