Skip to content

Commit

Permalink
fix: /home command does not work with respawn anchor
Browse files Browse the repository at this point in the history
- player.getRespawnTarget no longer consume itself
  • Loading branch information
jimchen5209 committed Nov 14, 2024
1 parent ab58ec1 commit 986f553
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/main/kotlin/one/oktw/galaxy/command/commands/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ class Home : Command {
lock -= player.uuid
} else {
main?.launch {
// Add back charge in countdown stage
val world = source.server.getWorld(player.spawnPointDimension)
if (world != null) {
val blockState = world.getBlockState(spawnPointPosition)
if (blockState.block is RespawnAnchorBlock) {
world.setBlockState(
spawnPointPosition, blockState.with(RespawnAnchorBlock.CHARGES, blockState[RespawnAnchorBlock.CHARGES] + 1)
)
world.updateNeighbors(spawnPointPosition, blockState.block)
}
}

for (i in 0..4) {
player.sendMessage(Text.translatable("Respond.commandCountdown", 5 - i).styled { it.withColor(Formatting.GREEN) }, true)
delay(TimeUnit.SECONDS.toMillis(1))
Expand All @@ -102,6 +90,12 @@ class Home : Command {
if (realWorld != null && realSpawnPointPosition != null) {
val blockState = realWorld.getBlockState(realSpawnPointPosition)
if (!player.notInAnyWorld && blockState.isOf(Blocks.RESPAWN_ANCHOR)) {
// Consume Respawn Anchor Charge
realWorld.setBlockState(
realSpawnPointPosition, blockState.with(RespawnAnchorBlock.CHARGES, blockState[RespawnAnchorBlock.CHARGES] - 1)
)
realWorld.updateNeighbors(realSpawnPointPosition, blockState.block)

player.networkHandler.sendPacket(
PlaySoundS2CPacket(
SoundEvents.BLOCK_RESPAWN_ANCHOR_DEPLETE,
Expand Down

0 comments on commit 986f553

Please sign in to comment.