check_head_swivel is expensive when you have a lot of mobs near (e.g. cow farm) #3278
Labels
No Label
#P1 CRITICAL
#P2: HIGH
#P3: elevated
#P4 priority: medium
#P6: low
#Review
annoying
API
bug
code quality
combat
commands
compatibility
configurability
contribution inside
controls
core feature
creative mode
delayed for engine release
documentation
duplicate
enhancement
environment
feature request
gameplay
graphics
ground content conflict
GUI/HUD
help wanted
incomplete feature
invalid / won't fix
items
looking for contributor
mapgen
meta
mineclone2+
Minecraft >= 1.13
Minecraft >= 1.17
missing feature
mobile
mobs
mod support
model needed
multiplayer
Needs adoption
needs discussion
needs engine change
needs more information
needs research
nodes
non-mob entities
performance
player
possible close
redstone
release notes
schematics
Skyblock
sounds
Testing / Retest
tools
translation
unconfirmed
mcl5
mcla
Media missing
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: VoxeLibre/VoxeLibre#3278
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
MineClone2 version: Master
What happened?
Game gets laggy when you have a lot of mobs in a small area, such as a cow farm. They sprint from corner to corner. Profiler runs and I get 8.09% usage just on check_head_swivel. This is single player only. It could be even worse on multiplayer. This is a lot of performance impact for a superficial feature. We probably need to make this more performant.
What should happen:
Game shouldn't be laggy.
Steps to reproduce
Make a cow farm with about around 30 cows
Initial check suggest every on_step it checks for objects within a 10 block radius and then decides it should look or not look at them based on random chance. I'm going to pull the random chance out and see if we should even bother looking around first by checking random chance is successful first. If this doesn't help, I'll delve deeper.
Minecraft has an Entity Format, where they store a lot of things, like
gaze_cooldown_ticks
. Maybe we should add a gaze cooldown too, and only look around when the cooldown is zero.That information is likely retrieved from looking at their code, so I won't be using that when designing a solution.
If it's talking about var names with a degree of confidence, we probably shouldn't consider this at all.
All we need is to use the idea of a cooldown for mobs gazing at players, which is better than constantly+randomly determining if a mob should look around.
A more ethical method would be for someone who owns MC to follow a cow around for example and keep following it while writing down how often it stops to look at you.
There's nothing unethical to use a simple idea as a cooldown. :) Besides, testing this in Minecraft would be a colossal waste of time, considering mobs gazing at players could be triggered and interfered by various factors.
I have reworked this a bit so it is less frequent and removed the checks that occur to earlier in the code to avoid wasteful searches of local thing: 02107971c95e33196ee305d17357d715a03ee508
There is still some way to go with this, but it went down locally from 8% to around 4%. It is worth revisiting but there is some complexity in the code and I went for the low hanging fruit.
I was going to say.... When did ethics become part of this? And, how is the "less ethical method" less "ethical"?
I own MC, and there's no way in heck, you're going to get me to follow an in-game cow around unless I need steaks.
Besides, you trip up the random aspect mobs looking at you by being close and in their line of sight.
I was speaking in the context of ethical as in not looking at the java source code.
Ok, but the wiki doesn't offer Java source code. They only code snippet that I know of, and I'm not sure it's directly copied from the source code, is the slime chunk formula.
Ahh, okay. thank you for explaining. lol. (It was a head-scratcher for me)