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 location shift in block_break so dropped items aren't placed into adjacent blocks. #1388

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

Lildirt
Copy link
Contributor

@Lildirt Lildirt commented Jul 26, 2024

If you call modify_event('drops', <any item array>) for block_break, there's a bit of a 'hack' in place to emulate this since BlockBreakEvent doesn't support rewriting drops natively.

Since we offset the location then do a dropItemNaturally call, it can sometimes send the item into another block, which causes it to shoot to the surface if they're underground. Not ideal.

I've attached links to two gifs. They're a bit large (and might play slow until they download fully). Hopefully it visualizes what happens.

Before: (~13MB) https://dirt.wtf/1ebnnKc8Pne20dm0.gif

After: (~8MB) https://dirt.wtf/VFB66bDgc6zGsRFa.gif

@PseudoKnight
Copy link
Contributor

PseudoKnight commented Jul 26, 2024

This was probably due to a misunderstanding of what dropItemNaturally() does at the time of writing this. Even though it's not documented, it seems to assume the Location is a Block location, so it adds 0.5 (with the random offset) to the coordinates.

It appears Minecraft vanilla also subtracts 0.125 (half the item entity height) from the randomized y position, which dropItemNaturally() does not do. It's not a big deal, but we could fix that too.

@Lildirt
Copy link
Contributor Author

Lildirt commented Jul 26, 2024

👍 Subtracting 0.125 from Y.

@PseudoKnight
Copy link
Contributor

PseudoKnight commented Jul 26, 2024

Want to rewrite the title of this issue before I pull? I can do it if you want. Something along the lines of fixing the position of modified item drops in block_break.

@Lildirt Lildirt changed the title Remove location shift from BukkitBlockListener as it places items into blocks in some cases. Fix location shift from BukkitBlockListener so dropped items aren't placed into adjacent blocks. Jul 26, 2024
@Lildirt Lildirt changed the title Fix location shift from BukkitBlockListener so dropped items aren't placed into adjacent blocks. Fix location shift in block_break so dropped items aren't placed into adjacent blocks. Jul 26, 2024
@PseudoKnight PseudoKnight merged commit 1a9ad32 into EngineHub:master Jul 26, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants