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

Remove separate eye height field from EntityEvent.Size #1171

Merged

Conversation

sciwhiz12
Copy link
Member

This PR resolves #1170 by removing the separate eye height field (and getter/setter) from EntityEvent.Size, and using the eye height stored in the EntityDimensions object instead.

Previously, the eye height was stored separately from the EntityDimensions, which explains why the event treated it separately. But in one of the 1.20 releases (I believe 1.20.5), the eye height is now part of the EntityDimensions object.

This PR also removes the now-unused Entity#getEyeHeightAccess accessor, since the eye height is now longer calculated by the getEyeHeight method it was accessing, and cleans up the javadoc for EntityEvent.Size.


FYI, @robotgryphon, one of us will have to update the javadoc for the event to use isAddedToLevel() per your PR #1166, depending on which one of us gets merged first.

The EntityDimensions object in the event now contains the eye height
(where previously it was stored separately in the entity).

Resolves neoforged#1170
The accessor is no longer used, as the eye height of the entity is
stored with the EntityDimensions.
@sciwhiz12 sciwhiz12 added bug A bug or error regression Worked previously but doesn't anymore 1.21 Targeted at Minecraft 1.21 labels Jun 23, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Jun 23, 2024

  • Publish PR to GitHub Packages

Last commit published: dc039d19d03c3d4a4e39c33b722db2d665ec8671.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1171' // https://github.com/neoforged/NeoForge/pull/1171
        url 'https://prmaven.neoforged.net/NeoForge/pr1171'
        content {
            includeModule('net.neoforged', 'neoforge')
            includeModule('net.neoforged', 'testframework')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1171.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1171
cd NeoForge-pr1171
curl -L https://prmaven.neoforged.net/NeoForge/pr1171/net/neoforged/neoforge/21.0.39-beta-pr-1171-1.21-GH-1170-entityevent-size-eye-height/mdk-pr1171.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

Copy link
Contributor

@robotgryphon robotgryphon left a comment

Choose a reason for hiding this comment

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

Change itself appears fine. Curious about the relationship between the new size attributes, whether the Entit0Eventy.Size event is still useful or fired when that attribute changes?

@sciwhiz12
Copy link
Member Author

When the entity scale attribute changes (in a living entity), the living entity tick will notice the change (as it stores the previous scale value as the appliedScale field) and cause a refresh of the entity dimensions through refreshDimensions().

The value of the scale attribute is used in LivingEntity#getDimensions(Pose) (among other places), which is called by refreshDimensions() to determine the new entity dimensions, which then triggers the EntityEvent.Size.

Therefore, the event is still useful to control the final dimensions of the entity, but I believe developers will need to apply the scale value manually (from getScale()) if they are recreating the entity dimensions from the entity type's default EntityDimensions.

@neoforged-compatibility-checks

@sciwhiz12, this PR introduces breaking changes.
Fortunately, this project is currently accepting breaking changes, but if they are not intentional, please revert them.
Last checked commit: dc039d19d03c3d4a4e39c33b722db2d665ec8671.

Compatibility checks

neoforge (:neoforge)

  • net/neoforged/neoforge/event/entity/EntityEvent$Size
    • getOldEyeHeight()F: ❗ API method was removed
    • setNewEyeHeight(F)V: ❗ API method was removed
    • <init>(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Pose;Lnet/minecraft/world/entity/EntityDimensions;F)V: ❗ API method was removed
    • <init>(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Pose;Lnet/minecraft/world/entity/EntityDimensions;Lnet/minecraft/world/entity/EntityDimensions;FF)V: ❗ API method was removed
    • setNewSize(Lnet/minecraft/world/entity/EntityDimensions;Z)V: ❗ API method was removed
    • getNewEyeHeight()F: ❗ API method was removed
  • net/minecraft/world/entity/Entity
    • getEyeHeightAccess(Lnet/minecraft/world/entity/Pose;)F: ❗ API method was removed
  • net/neoforged/neoforge/event/EventHooks
    • getEntitySizeForge(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Pose;Lnet/minecraft/world/entity/EntityDimensions;F)Lnet/neoforged/neoforge/event/entity/EntityEvent$Size;: ❗ API method was removed
    • getEntitySizeForge(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Pose;Lnet/minecraft/world/entity/EntityDimensions;Lnet/minecraft/world/entity/EntityDimensions;F)Lnet/neoforged/neoforge/event/entity/EntityEvent$Size;: ❗ API method was removed

@sciwhiz12 sciwhiz12 merged commit 28d0463 into neoforged:1.21.x Jun 24, 2024
6 checks passed
@sciwhiz12 sciwhiz12 deleted the 1.21/GH-1170-entityevent-size-eye-height branch June 24, 2024 17:15
@sciwhiz12 sciwhiz12 added the breaking change Breaks binary compatibility label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21 Targeted at Minecraft 1.21 breaking change Breaks binary compatibility bug A bug or error regression Worked previously but doesn't anymore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EntityEvent.Size#setNewSize(x, true) doesn't set new eyeheight properly (regression)
3 participants