-
Notifications
You must be signed in to change notification settings - Fork 99
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 drops #563
Fix drops #563
Conversation
darksunlight
commented
Feb 13, 2022
•
edited
edited
- adds basic support for enchantments
- fixes item drops (visually) (1.15+)
- implements more accurate drops based on tools (types, enchantments) used (1.14+)
what's the status here ? |
I just have to
|
src/lib/playerDat.js
Outdated
@@ -34,7 +34,10 @@ async function read (uuid, spawnPoint, worldFolder) { | |||
pitch: playerData.Rotation.value.value[1], | |||
onGround: Boolean(playerData.OnGround.value) | |||
}, | |||
inventory: playerData.Inventory.value.value | |||
inventory: playerData.Inventory.value.value.map(nbtItem => { | |||
if (nbtItem.tag) nbtItem.tag.name = '' |
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.
Why
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.
nbtItem.tag.name would be undefined otherwise and would cause an error on join.
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.
if it's defined and not empty you're losing the value
but it sounds like the problem should be fixed wherever the error was happening instead of here
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.
nbtItem.tag.name is intended to be empty. It's just somehow lost during the saving process, and I don't know prismarine-nbt enough to figure out what caused it to omit this empty string value.
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.
can you do if (nbtItem.tag && nbtItem.tag == undefined)
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.
did it
@@ -16,7 +16,7 @@ module.exports.server = (serv, { version }) => { | |||
const itemPlaceHandlers = new Map() | |||
serv.placeItem = (data) => { | |||
const handler = itemPlaceHandlers.get(data.item.type) | |||
return handler ? handler(data) : { id: data.item.type, data: data.item.metadata } | |||
return handler ? handler(data) : (serv.supportFeature('theFlattening') ? {} : { id: data.item.type, data: data.item.metadata }) |
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 wrong
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 don't think I understand what you mean.
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.
why would we return nothing after the flattening ?
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.
placeItem is currently only used in the same file, handling the block_place packet from clients. It's destructured into id and data after being called, then the id is used to find the corresponding blocks. Blocks with the same ID as an item is not the corresponding block for the item when the item does not have a corresponding block post-flattening, so I return an empty object with ID undefined such that the wrong block won't be placed.
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.
In pre-flattening times however this can be used as a fallback for items that somehow don't have an item place handler as the old assumption is indeed true.
Sorry misclicked |
This PR is a collection of random stuff, some seems clearly good and some not obvious That or explaining more what is each of the 10 changes supposed to do ? |
@rom1504
|
@@ -215,6 +215,7 @@ module.exports.server = function (serv, { version }) { | |||
const pos = opt.pos | |||
let sample | |||
if (type === 'all') sample = serv.players | |||
else if (type === 'self') sample = serv.players.filter(p => p.id === selfEntityId) |
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 needs to be added in doc
@@ -287,17 +288,18 @@ module.exports.server = function (serv, { version }) { | |||
else return sample.slice(count) // Negative, returns from end | |||
} | |||
|
|||
serv.selectorString = (str, pos, world, allowUser = true) => { | |||
serv.selectorString = (str, pos, world, allowUser = true, ctxEntityId) => { |
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.
add in doc
I'm going to merge. If we get reports of things being broken due to that, I will revert, and the next steps will be to create many small PRs doing one unitary changes for this instead of this massive PR. |