-
-
Notifications
You must be signed in to change notification settings - Fork 921
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
feat: Add optimistic update for block placement #3391
base: master
Are you sure you want to change the base?
Conversation
The code changes in `place_block.js` introduce an optimistic update feature for block placement. This feature sets the default state of the block being placed based on the held item. It retrieves the default state from the `minecraft-data` module and updates the block state at the destination accordingly. This optimistic update improves the responsiveness of block placement. Note: This suggested commit message follows the convention of using a prefix to indicate the type of change (`feat` for a new feature).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what native client does
What version does this apply to and do you have a source for that?
const heldItem = bot.heldItem | ||
const mcData = require('minecraft-data')(bot.version) | ||
const defaultState = mcData.blocksByName[heldItem?.name]?.defaultState | ||
if (defaultState) { | ||
bot.world.setBlockStateId(dest, defaultState) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This should be using the registry
- This is not a correct way to deduce correct block state from an item
- If world state is mutated then you must ensure that the data is fully in sync with the server (how does this handle the case where the server rejects?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I already answered 3rd question in the description. If the server rejects a block update would be emitted (even if it's air) as this is what the native client also does.
Can you elaborate on the 2nd question?
I don't know how to find things in the native client source I could check it by launching the client. This was always the behaviour of minecraft client. |
This is what native client does. It is important if the ping is low and after placement, calculates physics correctly. If the placement is not allowed the block is still updated to air by the server.
Maybe it's worth adding it as a setting to not break existing behaviors, but I don't see a reason why it shouldn't be enabled by default .