Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix some issues with the retract event & sticky pistons

Open Machine-Maker opened this issue 1 year ago • 9 comments

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.

Machine-Maker avatar Jun 04 '23 04:06 Machine-Maker

Rebased for 1.20.4. Tested by @Lulu13022002

Machine-Maker avatar Dec 18 '23 04:12 Machine-Maker

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.

Thorinwasher avatar Feb 14 '24 13:02 Thorinwasher

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().

Krakenied avatar Mar 18 '24 02:03 Krakenied

https://github.com/PaperMC/Paper/assets/46192742/f33fb12b-a480-43f4-a5ba-3323d32ffd25

Krakenied avatar Mar 18 '24 02:03 Krakenied

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.

Machine-Maker avatar Mar 20 '24 21:03 Machine-Maker

https://github.com/PaperMC/Paper/assets/46192742/f9ac2bb5-1cab-4231-bb15-99111a03113f

Works properly, I tested cancelling too and it works as well.

Krakenied avatar Mar 26 '24 10:03 Krakenied

Waiting for this PR, working well on my tests ! :D

WarnDa avatar Apr 07 '24 19:04 WarnDa

I'm waiting this PR too :)

NoltoxGit avatar Apr 07 '24 21:04 NoltoxGit

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.

Krakenied avatar Apr 08 '24 09:04 Krakenied