entity activation: use kd-tree for players and dedup entities#528
entity activation: use kd-tree for players and dedup entities#528hayanesuru wants to merge 3 commits into
Conversation
4a3617e to
8990589
Compare
99c8a9c to
7e32352
Compare
7e32352 to
5f16578
Compare
Dreeam-qwq
left a comment
There was a problem hiding this comment.
Since we added a more efficient activation range impl here, do we still need to optimize the original activation range impl?
And I think we don't need to build K-D Tree 3D if the dab is disabled.
d098e6e to
33ab76d
Compare
| } | ||
|
|
||
| - return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(wakeUpDuration * wakeUpDurationRandom.nextGaussian(1, deviation)))); | ||
| + return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(wakeUpDuration * (1.0 + deviation * entity.random.nextGaussian())))); // Leaf - optimize entity activation |
There was a problem hiding this comment.
It's better to move this change to the original patch Variable-entity-wake-up-duration.patch, since there is an existing patch in Leaf, no need to use another patch to make this kind of changes.
| : dx * dx + dy * dy; | ||
| } | ||
|
|
||
| public boolean isEmpty() { |
There was a problem hiding this comment.
If it's a method that may be used in the future, you can add a comment to note that.
| + (dontEnableIfInWater || entity.getType().is(net.minecraft.tags.EntityTypeTags.CAN_BREATHE_UNDER_WATER) || !entity.isInWater())) { // Leaf - Option for dontEnableIfInWater | ||
| + int distSq = (int) player.distanceToSqr(entity); | ||
| + a = distSq > startSq ? | ||
| + Math.min(maxPriority, Math.max((int) (distSq * scale), 1)) : |
There was a problem hiding this comment.
Any reason you changed original impl from "int + shift" to "double + scale"?
| - entity.activatedPriority = 1; | ||
| + a = 1; | ||
| } | ||
| + entity.activatedPriority = reset.add(entity.getId()) ? a : Math.min(a, entity.activatedPriority); |
There was a problem hiding this comment.
Hmmmm, I think using IntOpenHashSet here is slower than using a boolean to handle the reset in the original impl?
No description provided.