From 4c1ae304b685d8a0ec058c66f2ee2b665b4f7673 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Wed, 22 Nov 2023 21:20:57 +0100 Subject: [PATCH] simplify block breaking a bit --- docs/blocks/index.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/blocks/index.md b/docs/blocks/index.md index ef2f8f51d..85ad1ba7d 100644 --- a/docs/blocks/index.md +++ b/docs/blocks/index.md @@ -107,12 +107,11 @@ Block placement logic is called from `BlockItem#useOn` (or some subclass's imple ### Breaking a Block -Breaking a block is a bit more complex, as it requires time. The process can be roughly divided into four stages: "initiating", "mining", "actually breaking" and "finishing". +Breaking a block is a bit more complex, as it requires time. The process can be roughly divided into three stages: "initiating", "mining" and "actually breaking". - When the left mouse button is clicked, the "initiating" stage is entered. - Now, the left mouse button needs to be held down, entering the "mining" stage. **This stage's methods are called every tick.** - If the "continuing" stage is not interrupted (by releasing the left mouse button) and the block is broken, the "actually breaking" stage is entered. -- Under all circumstances, no matter if the block was actually broken or not, the "finishing" stage is entered. Or for those who prefer pseudocode: @@ -126,7 +125,6 @@ while (leftClickIsBeingHeld()) { break; } } -finishingStage(); ``` The following subsections further break down these stages into actual method calls. @@ -143,8 +141,8 @@ The following subsections further break down these stages into actual method cal #### The "Mining" Stage - `PlayerInteractEvent.LeftClickBlock` is fired. If the event is canceled, the pipeline moves to the "finishing" stage. - - Note that when the event is canceled on the client, no packets are sent to the server and thus no logic runs on the server. - - However, canceling this event on the server will still cause client code to run, which can lead to desyncs! + - Note that when the event is canceled on the client, no packets are sent to the server and thus no logic runs on the server. + - However, canceling this event on the server will still cause client code to run, which can lead to desyncs! - `Block#getDestroyProgress` is called and added to the internal destroy progress counter. - `Block#getDestroyProgress` returns a float value between 0 and 1, representing how much the destroy progress counter should be increased every tick. - The progress overlay (cracking texture) is updated accordingly. @@ -163,10 +161,6 @@ The following subsections further break down these stages into actual method cal - Server-only: `IBlockExtension#getExpDrop` is called. - Server-only: `Block#popExperience` is called with the result of the previous `IBlockExtension#getExpDrop` call, if that call returned a value greater than 0. -#### The "Finishing" Stage - -- The internal destroy progress counter is reset. - ### Ticking Ticking is a mechanism that updates (ticks) parts of the game every 1 / 20 seconds, or 50 milliseconds ("one tick"). Blocks provide different ticking methods that are called in different ways.