Paper
Paper copied to clipboard
Fix some issues with the retract event & sticky pistons
Reported by @Lulu13022002 and SPIGOT-2677.
When cancelling the retract event for sticky pistons, the piston head did not stay extended but the "stickyied" blocks were left behind. This doesn't match the normal piston behavior of keeping the head extended.
Root of the issue is that sticky events are called later due to need to collect the blocks being moved.
I didn't find any issues, and observers function correctly, not updating when the retract event is cancelled, but this could break some obscure redstone mechanic I'm not aware of.
Rebased for 1.20.4. Tested by @Lulu13022002
Found a bug: When the piston does not move a block during retraction, the event PistonRetractEvent will show an opposite facing compared to when it does move a block.
Found a bug: When the piston does not move a block during retraction, the event PistonRetractEvent will show an opposite facing compared to when it does move a block.
- First option: getDirection should return the actual piston moving direction
These two should use to enumdirection.getOpposite()
to fix that:
https://github.com/PaperMC/Paper/pull/9258/files#diff-e7381a22d3936796a90f4898d99ec21d6099cc8e49f45267c11841c942feb240R78
https://github.com/PaperMC/Paper/pull/9258/files#diff-e7381a22d3936796a90f4898d99ec21d6099cc8e49f45267c11841c942feb240R108
However I'm not sure if it is not actually the correct behavior. Probably it is:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockPistonEvent.html#getDirection()
Return the direction in which the piston will operate.
- Second option: getDirection should return the piston block face
If it's actually correct, then it requires some changes as well - this one (above the line referenced in the diff - it's in else
):
https://github.com/PaperMC/Paper/pull/9258/files#diff-e7381a22d3936796a90f4898d99ec21d6099cc8e49f45267c11841c942feb240R166
ought to be changed to use getOpposite()
.
https://github.com/PaperMC/Paper/assets/46192742/f33fb12b-a480-43f4-a5ba-3323d32ffd25
Ok, I think the correct solution is for getDirection to return the same value regardless of if its an extend or retract, just returning the direction the piston head is relative to the block itself.
https://github.com/PaperMC/Paper/assets/46192742/f9ac2bb5-1cab-4231-bb15-99111a03113f
Works properly, I tested cancelling too and it works as well.
Waiting for this PR, working well on my tests ! :D
I'm waiting this PR too :)
Ok, I think the correct solution is for getDirection to return the same value regardless of if its an extend or retract, just returning the direction the piston head is relative to the block itself.
However it will break plugins behavior on Spigot. Especially plugins tracking sticky pistons blocks movement as on Spigot the method (for sticky pistons) returns piston head direction for extend and the opposite for retract. It's not ideal though as well because currently on Spigot normal piston event getDirection method returns piston head direction for both extend and retract. There is one more inconsistency on Spigot too - the sticky piston doesn't fire retract event if there is no blocks attached to it.