Skip to content

Commit

Permalink
Merge pull request #440 from OKTW-Network/fix-harvest
Browse files Browse the repository at this point in the history
Fix hand events
  • Loading branch information
mergify[bot] authored Aug 18, 2024
2 parents 0b4b104 + cdf6043 commit c6c614f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/one/oktw/galaxy/item/event/Wrench.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2023
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -79,6 +79,7 @@ class Wrench {
startDirection[player] = blockPos to direction

blockEntity.facing = if (next == -1 || next > allowedFacing.lastIndex) allowedFacing.first() else allowedFacing[next]
return true
}

// Check destructible
Expand Down Expand Up @@ -213,7 +214,8 @@ class Wrench {

world.setBlockState(blockPos, newState)
world.updateNeighbor(newState, blockPos, newState.block, blockPos, true)
Block.postProcessState(newState, world, blockPos).let { if (!it.isAir) world.setBlockState(blockPos, it, 2) }
// Workaround disable state update for bell
Block.postProcessState(newState, world, blockPos).let { if (!it.isAir && it.block != BELL) world.setBlockState(blockPos, it, 2) }

return true
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/one/oktw/galaxy/player/Harvest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2023
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -44,7 +44,11 @@ class Harvest {
val blockPos = event.packet.blockHitResult.blockPos
val blockState = world.getBlockState(blockPos)

if (event.packet.hand == Hand.MAIN_HAND && !player.isSneaking && isMature(world, blockPos, blockState)) {
if (
event.packet.hand == Hand.MAIN_HAND &&
(!player.isSneaking || (player.mainHandStack.isEmpty && player.offHandStack.isEmpty)) &&
isMature(world, blockPos, blockState)
) {
event.cancel = true
val block = blockState.block
val ageProperties = when (block) {
Expand Down

0 comments on commit c6c614f

Please sign in to comment.