Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hand events #440

Merged
merged 4 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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