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

feat(api/entity): add EntityEvent.Push when an entity is pushed #9678

Open
wants to merge 1 commit into
base: 1.20.x
Choose a base branch
from

Conversation

danorris709
Copy link

This PR is a continuation of the conversation from #9675.

Reason

The main reason I initially wanted to be able to modify the entity's push reaction was to prevent players from being pushed when in a specific GUI. In lower versions this was achievable by modifying the "pushthrough" variable on the Entity however, this was later removed by Mojang in favour of the "isPushable" method. In changing it to use this method they unfortunately removed the capability to prevent entities from being pushed outside of extending the entity and using your own class.

Details

Originally I added an event called when the isPushable method was called. However, when discussing the useful-ness I realized that perhaps adding functionality for modifying the push reaction would be more widely useful. There is only one other instance that this event doesn't cover which is the ItemFrame's push implementation as it eventually calls super anyway

From ItemFrame.java:

   public void push(double p_31817_, double p_31818_, double p_31819_) {
      if (!this.fixed) {
         super.push(p_31817_, p_31818_, p_31819_);
      }

   }

The only other consideration I had when making this PR was that potentially someone would want the "cause" of the push. There is a method LivingEntity#doPush however, it is a protected method and only defers to Entity#push. TL;DR: Currently I don't think it is pheasible to include the cause without creating a lot of changes in the Mojang code (which I assume is undesirable)

@autoforge autoforge bot added Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. 1.20 labels Jul 21, 2023
@autoforge autoforge bot requested a review from a team July 21, 2023 15:42
@danorris709
Copy link
Author

Here is a GIF of the cow and player interactions from the test mod

@autoforge autoforge bot added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Sep 21, 2023
@autoforge
Copy link

autoforge bot commented Sep 21, 2023

@danorris709, this pull request has conflicts, please resolve them for this PR to move forward.

@autoforge autoforge bot removed the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Sep 21, 2023
@autoforge autoforge bot added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Dec 6, 2023
@autoforge
Copy link

autoforge bot commented Dec 6, 2023

@danorris709, this pull request has conflicts, please resolve them for this PR to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20 Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant