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

Prevent headless pistons deleting walls #3717

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

traksag
Copy link
Contributor

@traksag traksag commented Jun 30, 2022

Overview

Fixes #3716

Description

Cancel the retract event when a sticky piston faces the plot wall (or into a plot area) and retracts with no blocks attached to it. The effect: the plot wall block doesn't get deleted and the headless sticky piston will turn into a normal sticky piston.

Some things to take note of:

  • If a headless sticky piston has more than 1 block in front of it, the piston retract event doesn't seem to fire. In that case the block directly in front of the headless piston also doesn't get deleted. So we don't need to worry about this case.
  • Headless non-sticky pistons don't seem to delete the block in front of them. So we can ignore non-stickies. Note that non-stickies have block type PISTON instead of MOVING_PISTON in this event.
  • It is somewhat important to only handle sticky pistons with no blocks in front of them, because BlockPistonRetractEvent#getDirection is the direction the blocks move in if the block list is non-empty, and otherwise the facing direction of the piston.

Submitter Checklist

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

@traksag traksag requested a review from a team as a code owner June 30, 2022 23:33
Copy link
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested, but LGTM

@NotMyFault NotMyFault added the Bugfix This PR fixes a bug label Jul 1, 2022
@NotMyFault NotMyFault requested a review from a team July 1, 2022 09:06
@dordsor21
Copy link
Member

A check for the block being outside the min/max build heights of the plot area would also be an idea. See the usages of PlotArea#buildRangeContainsY in other events (I'm assuming the same issue will be present for this case as well)

@NotMyFault
Copy link
Member

@traksag Do you want to address the PR feedback?

@traksag
Copy link
Contributor Author

traksag commented Aug 20, 2022

Sure, I kinda forgot about it. Will probably crack something out over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix This PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pistons can delete plot walls
3 participants