-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Separate tick count to ensure vanilla parity #12077
base: main
Are you sure you want to change the base?
Conversation
paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch
Outdated
Show resolved
Hide resolved
9254a91
to
f28a08b
Compare
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.
In the despawn time check inside Entity#tick, totalEntityAge should also be used instead if we don't want unloading to affect their configured despawn time.
@@ -860,7 +861,7 @@ | |||
+ // CraftBukkit start | |||
+ // Spigot start | |||
+ if (this instanceof net.minecraft.world.entity.LivingEntity) { | |||
+ this.tickCount = compound.getInt("Spigot.ticksLived"); | |||
+ this.totalEntityAge = compound.getInt("Spigot.ticksLived"); // Paper |
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.
Kinda unrelated to this PR but, is there still a reason to only read this if the entity is a living entity?
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.
Entity despawn now uses the totalEntityAge
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.
Kinda unrelated to this PR but, is there still a reason to only read this if the entity is a living entity?
Spigot api resets tickCount for non-living entities, so leaving it here just for api behavior is same as spigot.
Closes #12075.
This pull request introduces another entity tick counter
totalTickCount
for api usage, reset vanillatickCount
instead of restoring value from Spigot'sSpigot.ticksLived
tag to keep vanilla parity.Analysis
Spigot's restore tickCount behavior(See original patch) causes potential issues with Wither's ai, see code below, and lead to wither loses its target when entities are reloaded:
![image](https://private-user-images.githubusercontent.com/102713261/411039996-7c6f9b6c-4b26-42d9-b9df-c6568c73309d.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NjQ4MzcsIm5iZiI6MTczOTQ2NDUzNywicGF0aCI6Ii8xMDI3MTMyNjEvNDExMDM5OTk2LTdjNmY5YjZjLTRiMjYtNDJkOS1iOWRmLWM2NTY4YzczMzA5ZC5qcGVnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMTYzNTM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjE5OWY1ZTlhNjExYzliOTgyZTQ4MWY2MTYzN2IzZDIyYTI4M2RiM2NlOTIyMDAzM2NiZTdhZWI4NDEwYTc3MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Jk0JVw-RTRPAZak7HVx_pNxqENIFnTNaQjYA85q2oLw)
Api Changes
Now
Entity#getTicksLived
gets value from totalTickCount to avoid api behavior breakage,Entity#setTicksLived
sets bothtickCount
andtotalTickCount
.Currently the totalTickCount is only used for apis, if the breakage is fine, the extra counter can be removed.