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

Reset breaking block state when sneak status changes #810

Open
Fyoncle opened this issue Feb 15, 2025 · 8 comments
Open

Reset breaking block state when sneak status changes #810

Fyoncle opened this issue Feb 15, 2025 · 8 comments

Comments

@Fyoncle
Copy link

Fyoncle commented Feb 15, 2025

Edit

When a block stats breaking, if the player is in a wrong state (ie mod disabled) then the mod doesn;t activates and the block is broken at normal speed. If, before the block breaks, the player gets into a valid state (mod enabled), then the mod activates and the whole tree falls. This leads to bypassing the settings for the custom break speed when it is set to something else than 0.

The idea here is to be able to stop the current breaking progress when the mod reactivates so the proper breaking duration is applied.

Describe the bug

Same issue in Tree Harvester, check this issue for more explanation:
Serilum/.issue-tracker#2126

He tried to fix that, and he did. But this introduced another bug which is a issue i opened:
Serilum/.issue-tracker#2659

Minecraft version

1.20.1

Fabric API version

0.92.2

Mod version

4.3.4

Configuration

All default

Relevant log output

No need
@Rakambda
Copy link
Member

Not sure I can do much about it. When you break the tree, a "block broken event" is sent by fabric/forge. When this happens the player's state is checked https://github.com/RakambdaOrg/FallingTree/blob/minecraft/1.21.4/common/src/main/java/fr/rakambda/fallingtree/common/tree/TreeHandler.java#L58 -> https://github.com/RakambdaOrg/FallingTree/blob/minecraft/1.21.4/common/src/main/java/fr/rakambda/fallingtree/common/FallingTreeCommon.java#L87

The crouching state is whatever is reported by the server at that moment. If it is falsly recognized then I dunno... If the sever says your crouching (but your're not) then I won't be able to guess it.

@Fyoncle
Copy link
Author

Fyoncle commented Feb 15, 2025

Not sure I can do much about it. When you break the tree, a "block broken event" is sent by fabric/forge. When this happens the player's state is checked https://github.com/RakambdaOrg/FallingTree/blob/minecraft/1.21.4/common/src/main/java/fr/rakambda/fallingtree/common/tree/TreeHandler.java#L58 -> https://github.com/RakambdaOrg/FallingTree/blob/minecraft/1.21.4/common/src/main/java/fr/rakambda/fallingtree/common/FallingTreeCommon.java#L87

The crouching state is whatever is reported by the server at that moment. If it is falsly recognized then I dunno... If the sever says your crouching (but your're not) then I won't be able to guess it.

I think you misunderstood, if you stop pressing shift after it starts to break the tree, that happens

@Rakambda
Copy link
Member

Rakambda commented Feb 15, 2025

What happens? I'm not too sure to understand. Maybe a little video would help seeing the issue.
With default config? (yeah writen in original post, my bad)

@Fyoncle
Copy link
Author

Fyoncle commented Feb 15, 2025

What happens? I'm not too sure to understand. Maybe a little video would help seeing the issue. With default config? (yeah writen in original post, my bad)

Steps to reproduce:

  1. (I use shift to enable the mod)
  2. Start breaking the tree when shift is NOT pressed.
  3. When that one single block about to break without using falling trees mod, you immediately press shift before it breaks, and it causes the whole tree to break instead of that 1 block without waiting all this duration to break one tree.

@Rakambda
Copy link
Member

Rakambda commented Feb 15, 2025

  1. Ok so not default config

  2. So, to me by itself this isn't an issue but intended behaviour. At the moment of the log breaking, the requirement is indeed true, "you are crouching" so the mod activates and breaks everything.

However your point is maybe more that in that case it doesn;t respect the "breaking speed" that is configured ?

@Fyoncle
Copy link
Author

Fyoncle commented Feb 15, 2025

  1. Ok so not default config
  2. So, to me by itself this isn't an issue but intended behaviour. At the moment of the log breaking, the requirement is indeed true, "you are crouching" so the mod activates and breaks everything.

However your point is maybe more that in that case it doesn;t respect the "breaking speed" that is configured ?

Kinda, you can break a hugeeee tree under 1 second using this bug

@Rakambda
Copy link
Member

Not really sure if I wanna "fix"that edge case. The thing is the way it is implemented in Minecraft is a bit wanky.

When you start breaking a block, the client will calculate how long it will take based on the tool + block. What fallingtree do is just add its part into it and say "okay it'll take 5x longer" for example. The same thing happens on the server side, and when the breaking time is over then the block is broken (on the client is disappears, and on the server lots of things happens).

But, this thing is just done once when the block starts to be broken. It'd require lots more hooking into the client to handle this based on the change of the crouching state. And FallingTree tries to be as much server-sided as possible, I don't want to require it too much on clients.

I'll keep the issue open as a possible enhacement, but honestly I probably won't invest much time on it ; seems a bit hacky to perform this with the way MC works. (If people wanna make PRs for this i'm open to integrate it ofc).

@Rakambda Rakambda added type: 🧱 enhancement New feature or request modloader: Forge modloader: Neoforge and removed type: 🐛 bug Something isn't working labels Feb 15, 2025
@Rakambda Rakambda changed the title Releasing Sneak still mines the whole tree Reset breaking block state when sneak status changes Feb 15, 2025
@Fyoncle
Copy link
Author

Fyoncle commented Feb 15, 2025

Not really sure if I wanna "fix"that edge case. The thing is the way it is implemented in Minecraft is a bit wanky.

When you start breaking a block, the client will calculate how long it will take based on the tool + block. What fallingtree do is just add its part into it and say "okay it'll take 5x longer" for example. The same thing happens on the server side, and when the breaking time is over then the block is broken (on the client is disappears, and on the server lots of things happens).

But, this thing is just done once when the block starts to be broken. It'd require lots more hooking into the client to handle this based on the change of the crouching state. And FallingTree tries to be as much server-sided as possible, I don't want to require it too much on clients.

I'll keep the issue open as a possible enhacement, but honestly I probably won't invest much time on it ; seems a bit hacky to perform this with the way MC works. (If people wanna make PRs for this i'm open to integrate it ofc).

Understood, thanks for minding to leave it open anyway. Have a nice day ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants