-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Entity Helper Cleanup #2369
Entity Helper Cleanup #2369
Conversation
Often these NMS impls are made because the spigot-provided API wasn't enough. Have you validated every one of these changes through script, paying special attention also to the types of entities these work on (LivingEntity vs Entity vs ...)? Also, have you validated this new API is also available on previous versions? Sometimes API is added but not backported via Spigot. |
I tested all of these changes, obviously there could always be obscure edge-cases that the NMS impls were added for and I missed, but just to go over the few possibly more problematic changes:
Let me know if there are any other changes you're wondering about ^
I referenced https://helpch.at/docs/1.16.5 and tested on |
|
||
public void setGhastAttacking(Entity entity, boolean attacking) { | ||
public void setGhastAttacking(Entity entity, boolean attacking) { // TODO: 1.19 - Ghast#setCharging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this has API in 1.19, remove the UnsupportedOperationException
and remove the 1.19 impl, and make the interface impl use the API method (ie so old versions use NMS and new versions don't, and so we know more easily this is ready to remove once there are no implementing modules) (and still leave a // TODO: once minimum version is 1.19 or higher, remove from NMS
comment as well of course)
(also for the record // TODO: 1.19 - ...
would indicate an issue has been introduced by the 1.19 update and needs to be addressed ASAP)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed
@@ -58,12 +57,7 @@ else if (npc.getEntity() instanceof Player) { | |||
((Player) npc.getEntity()).sleep(bedLocation.clone(), true); | |||
} | |||
else { | |||
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted on discord, given that the only special case here is a very old version, better to not touch the 1.16 special case unless you're 100% confident this change is entirely correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
@@ -3724,7 +3731,12 @@ else if (getBukkitEntity() instanceof Creeper) { | |||
// Sets whether the ghast entity should show the attacking face. | |||
// --> | |||
if (mechanism.matches("ghast_attacking") && mechanism.requireBoolean()) { | |||
NMSHandler.entityHelper.setGhastAttacking(getBukkitEntity(), mechanism.getValue().asBoolean()); | |||
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { // TODO: 1.19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't put that // TODO
comment, the NMSVersion
usage is the indicator
Changes
getFishHook
was removed as the API it used is the same on all supported versions.get/setAbsorption
was removed as the API it used was the same on all supported versions.setSleeping
was removed in favor of the newEntityHelper#setPose
.setSneaking
's NMS implementations were removed in favor of an implementation usingEntityHelper#setPose
.getDiscoveredRecipes
was removed in favor ofHumanEntity#getDiscoveredRecipes
.getRawHoverText
was removed as it wasn't used anywhere (as far as I could see) and all of it's implementations just threw anUnsupportedOperationException
.get/setBodyArrows
were removed as they just calledLivingEntity#get/setArrowsInBody
with no NMS implementation.get/setArrowPickupStatus
was removed as the API it used is the same on all supported versions.get/setItemFromTrident
were removed as it wasn't used anywhere.get/setSpeed
were removed as all they did was get/set the speed attribute's base value, which is possible with API.get/setShulkerPeek
were removed in favor ofShulker#get/setPeek
.setGhastAttacking
's 1.19 Implementation was removed in favor ofGhast#setCharging
, and a TODO comment was added.EntityPickupStatus
property was changed to useAbstractArrow
instead ofArrow
.getBoundingBox
was removed in favor ofEntity#getBoundingBox
.com.denizenscript.denizen.nms.util.BoundingBox
class was removed in favor of Bukkit'sBoundingBox
- all relevant code has been updated.1.16
EntityHelper implementation to directly callsetPose
instead of using reflection as it... doesn't seem to be necessary?Additions
EnitityHelper#setPose
sets an Entity's pose. added as an all-in-one replacement for other methods which did the same thing.