MarkusBordihn / BOs-Adaptive-Performance-Tweaks

Adaptive Performance Tweaks is a collection of Minecraft Forge server-side Mod which automatically adjust specific settings on the server to allow a more balanced TPS/FPS.
Other
4 stars 2 forks source link

Make named mobs not able to be despawned. #43

Closed TheInfamousAlk closed 1 year ago

TheInfamousAlk commented 1 year ago

Is your feature request related to a problem? Please describe. Sometimes people's pets will despawn when the Mobs module is enabled.

Describe the solution you'd like It would be awesome if named mobs are completely ignored in the total mob count per chunk maximum. Or at least make named mobs unable to be despawned by the mod.

Describe alternatives you've considered For now, we've disabled this module of APTweaks due to pets disappearing. The performance impact is harsh though, and we would really like to re-enable this.

Additional context We noticed this behavior on the Cottage Witch modpack official server, when there were a high number of players online, often above 15. This mod has saved the server from lag with this high of a player count but is now struggling since we've disabled the mobs module because of pet disappearances.

katubug commented 1 year ago

Just commenting to back this up! We had a lot of passive animals like sheep and cows go poof, as well as tamed animals like frogs (tamed with Domestication Innovation mod).

Ideally the server would despawn non-hostile mobs only as a last resort, and never despawn any that are Nametagged or wearing a Domestication Innovation collar. It would also be great if the config allowed us to blacklist entire entity types from being despawned (let me know if it does this already and I'm being a goober).

I would love to add this back to our modpack if possible! Please let us know if these things are doable.

And thank you very much for this suite of mods. They help a ton!!

MarkusBordihn commented 1 year ago

Thanks a lot for the report. But the mod is already ignoring all mobs with custom names (which include name tags) and all tamed animals like:

        || (entity instanceof TamableAnimal tamableAnimal && tamableAnimal.getOwner() != null)
        || (entity instanceof Bee bee && bee.hasHive()) || entity.hasCustomName());

Source: https://github.com/MarkusBordihn/BOs-Adaptive-Performance-Tweaks/blob/1.18.2/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java#LL403C1-L404C84

Which means if you have any issues with tamed animals or with a custom named (name tag) it's very likely not related to this mod or these are custom animals which are not covered by this check.

In general the mod is not doing any de-spawning by itself, it's only blocking the spawn event, but is not performing any de-spawning of existing mobs.

Could you please provide a debug.log in the case you are able to reproduce this kind of de-spawning. Make sure you are in creative, op or on the server console so that this is working.

  1. Enabled the debug with: /aptweaks debug spawn true
  2. Reproduce the issue.
  3. Disabled the debug with: /aptweaks debug spawn false

The debug will be saved in the logs/debug.log or logs/last.log file.

In general I'm happy to implement additional checks or anything else which could be helped in this case. But ignoring tamed animals or named mobs is already implemented and used by the mod. :/

katubug commented 1 year ago

In that case, I owe you an apology. I was the one who made the assumption that your mod was responsible for the despawning of animals, and I didn't do my due diligence in testing. I asked Alk to make this suggestion on our behalf.

I'll do the tests when I have time and I'll get back to you as to whether this issue is replicatable, or if I was being too hasty. Thanks for your response!

On Thu, Apr 6, 2023, 4:55 PM Markus Bordihn @.***> wrote:

Thanks a lot for the report. But the mod is already ignoring all mobs with custom names (which include name tags) and all tamed animals like:

    || (entity instanceof TamableAnimal tamableAnimal && tamableAnimal.getOwner() != null)
    || (entity instanceof Bee bee && bee.hasHive()) || entity.hasCustomName());

Source: https://github.com/MarkusBordihn/BOs-Adaptive-Performance-Tweaks/blob/1.18.2/core/src/main/java/de/markusbordihn/adaptiveperformancetweakscore/entity/CoreEntityManager.java#LL403C1-L404C84

Which means if you have any issues with tamed animals or with a custom named (name tag) it's very likely not related to this mod or these are custom animals which are not covered by this check.

In general the mod is not doing any de-spawning by itself, it's only blocking the spawn event, but is not performing any de-spawning of existing mobs.

Could you please provide a debug.log in the case you are able to reproduce this kind of de-spawning. Make sure you are in creative, op or on the server console so that this is working.

  1. Enabled the debug with: /aptweaks debug spawn true
  2. Reproduce the issue.
  3. Disabled the debug with: /aptweaks debug spawn false

The debug will be saved in the logs/debug.log or logs/last.log file.

In general I'm happy to implement additional checks or anything else which could be helped in this case. But ignoring tamed animals or named mobs is already implemented and used by the mod. :/

— Reply to this email directly, view it on GitHub https://github.com/MarkusBordihn/BOs-Adaptive-Performance-Tweaks/issues/43#issuecomment-1499671203, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7XE5RABFU5N3IZ5DFKTLTW743VFANCNFSM6AAAAAAWV44UHM . You are receiving this because you commented.Message ID: @.*** .com>

katubug commented 1 year ago

I'm not sure how to replicate this issue, now that I'm back at my PC. I think I will just be adding the mod back in, and we'll keep a closer eye on pets and such. I do have two questions, though.

Firstly, does the tamed check that you run have compatibility with Domestication Innovation? https://www.curseforge.com/minecraft/mc-mods/domestication-innovation - I dug into the jar but I'm a noob so I'm still unsure. I do see a reference (in the refmap) to "TamableAnimal" but it seems to refer to "isAlliedTo" and not a reference to the owner? I have no idea if that's relevant or if I'm even looking in the right place.

In that mod, there's an item called a Collar, which is enchantable and equippable to pets. Would you be able to implement a check for that?

I'm also worried about entities from the Luggage mod, which I'd like to fully blacklist from ever being affected by the mod. Is that something I can do via the config?

Thanks again for your time.

MarkusBordihn commented 1 year ago

Thanks for the detailed feedback. I checked the domestication innovation mod and they are using the standard implementation for the owner and custom name, so this should work out of the box.

image

You can see this data over /data get entity <entity UUID or auto complete>, so as long Owner or CustomName is set correctly the entity will be ignored.

The Luggage has also the Owner set, so they should be ignored as well. But only if they are owned, un-owned entities could be still blocked from spawning.

image

There is a config file for each module, so in this case you can adjust the spawn.toml file and spawnAllowList entry to ignore an entity from the spawn optimization regardless if they are owned or un-owned.

MarkusBordihn commented 1 year ago

I just released an update which should cover some custom modded entities which are not extending the TamableAnimal class. Let me know if you found any specific issue and I'm happy to take a deeper look into it.

I will leave this issue report open for the next 1-2 weeks.

katubug commented 1 year ago

Thank you so much for the information and the update! I've re-added the mod and I'll be putting out the modpack update in the next few days, so I'll be able to let you know then if there are any issues. I don't expect there to be.

Thank you again. It's been a treat talking with you about this! And I apologize again for my initial carelessness.

On Fri, Apr 7, 2023, 8:10 AM Markus Bordihn @.***> wrote:

I just released an update which should cover some custom modded entities which are not extending the TamableAnimal class. Let me know if you found any specific issue and I'm happy to take a deeper look into it.

I will leave this issue report open for the next 1-2 weeks.

— Reply to this email directly, view it on GitHub https://github.com/MarkusBordihn/BOs-Adaptive-Performance-Tweaks/issues/43#issuecomment-1500276411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7XE5T76MQN4NISVQCN2IDXAAG2TANCNFSM6AAAAAAWV44UHM . You are receiving this because you commented.Message ID: @.*** .com>

Artzert2215 commented 1 year ago

Just commenting to back this up! We had a lot of passive animals like sheep and cows go poof, as well as tamed animals like frogs (tamed with Domestication Innovation mod).

Ideally the server would despawn non-hostile mobs only as a last resort, and never despawn any that are Nametagged or wearing a Domestication Innovation collar. It would also be great if the config allowed us to blacklist entire entity types from being despawned (let me know if it does this already and I'm being a goober).

I would love to add this back to our modpack if possible! Please let us know if these things are doable.

And thank you very much for this suite of mods. They help a ton!!

I'm having the same issue where animals like chickens or cows despawn, every so often when you check your farm the cow pen will be empty. Would you mind sharing a link to your modpack so I can find a common mod that may cause this?

I have yet to recreate this in singleplayer, my best guess is animals that are left in unloaded chunks despawn just like hostile mobs somehow.

ps: My modpack also contains this mod and one would think this one would cause the issues, that's how I found this thread.

katubug commented 1 year ago

Sure! It's here: https://www.curseforge.com/minecraft/modpacks/cottage-witch

Please let me know if you find anything!

On Sun, Apr 9, 2023, 12:51 PM Michael Peeters @.***> wrote:

Just commenting to back this up! We had a lot of passive animals like sheep and cows go poof, as well as tamed animals like frogs (tamed with Domestication Innovation mod).

Ideally the server would despawn non-hostile mobs only as a last resort, and never despawn any that are Nametagged or wearing a Domestication Innovation collar. It would also be great if the config allowed us to blacklist entire entity types from being despawned (let me know if it does this already and I'm being a goober).

I would love to add this back to our modpack if possible! Please let us know if these things are doable.

And thank you very much for this suite of mods. They help a ton!!

I'm having the same issue where animals like chickens or cows despawn, every so often when you check your farm the cow pen will be empty. Would you mind sharing a link to your modpack so I can find a common mod that may cause this?

I have yet to recreate this in singleplayer, my best guess is animals that are left in unloaded chunks despawn just like hostile mobs somehow.

— Reply to this email directly, view it on GitHub https://github.com/MarkusBordihn/BOs-Adaptive-Performance-Tweaks/issues/43#issuecomment-1501179962, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7XE5Q73SQVVV5W6TEELF3XALZJXANCNFSM6AAAAAAWV44UHM . You are receiving this because you commented.Message ID: @.*** .com>

Artzert2215 commented 1 year ago

Compared with my modpack (https://www.curseforge.com/minecraft/modpacks/all-around-low-tech-lite) These mods stood out as they could be related to the issue.

Adaptive Performance Tweaks Canary Easier Sleeping Fastload Pluto Rubidium Server Performance - Smooth Chunk Save[Forge/Fabric]

ps: nice modpack!

katubug commented 1 year ago

Thank you! I've come back to report that since adding this mod to the server - and not before - I've received 5-6 players saying that their farm animals and villagers have all despawned. Our TPS has been very low - like, under 10 - could that be why? For now I'll just add vanilla passives to the blacklist.

Also, we removed Canary.

MarkusBordihn commented 1 year ago

Thanks for the feedback. Villagers are considered as NPC which are automatically excluded from any optimization by this mod.

A TPS from 10 is consider "very_high", so the mod will block more spawn events then normally. The mod will log such blocked spawns during very high server loads with something like: [High Server Load] Blocked spawn event for... which means it should be easy to see in the debug log, if this is really the case.

If such blocking is still not helping, the server is basically overloaded and you need to find the root cause for it with Spark or so. There is no a lot such mod could do if the root cause is related to something else like chunk generation, active spawners, active blocks, ...

For my own server I'm using https://www.curseforge.com/minecraft/mc-mods/easy-mob-farm to make sure players have not huge mob farms to farm items.

It would be great to get a debug.log to be able to reproduce this kind of de-spawning and maybe to see if there is anything I could do in this specific case. Make sure you are in creative, op or on the server console so that this is working.

  1. Enabled the debug with: /aptweaks debug spawn true
  2. Reproduce the issue.
  3. Disabled the debug with: /aptweaks debug spawn false

Without these details I could only guess whats the reason for this. Passive mob can naturally despawn, if the player logs out or the server is restarting during a high load. See: https://minecraft-archive.fandom.com/wiki/Despawn#

If you server is overloaded and you need to kill some mobs, you could just change the gamemod to "peaceful" for a few seconds which will automatically kill all "hostile" mobs.