Changes to EntityControl

Discussion in 'Announcements' started by Matryoshika, Nov 16, 2019.

  1. Matryoshika

    Matryoshika Well-Known Member

    Messages:
    1,193
    Likes Received:
    606
    Local Time:
    10:51 PM
    Notice
    These changes are only applied to the 1.12 servers so far.
    The other servers will soon be updated as well.



    Introduction

    • What is EntityControl?
    EntityControl is a custom plugin made by MyM, and exists on all of our 1.7.10 and above servers.
    It is this plugin that enforces the "only so-and-so many entities are allowed to exist in a 3x3 chunk area" which many of you, members of the MyM community, are aware of.

    By default, a maximum amount of 40 Entities are allowed to exist within a 3x3 chunk area.
    Out of these 40, up to 30 of them are allowed to be animals, and up to 20 of them are allowed to be monsters, leading to any variation between [30 animals + 10 monsters] and [20 animals + 20 monsters].
    These limits can and are tweaked as necessary for each individual server.

    If this limit is met or exceeded, then new spawns are not allowed. If the limit has been exceeded, then entities are culled when the chunks are (re-)loaded.
    Many of you don't like how unpredictable this system in.

    This is where the new changes come in.

    The old EntityControl


    To explain exactly what has changed, I need to preface this with how they were culled.
    Every chunk has a list of many entity-specific lists, which contain entities inside of them. Something like a master-list containing a list of cows, a list of sheep, a list of zombies, and so forth.
    The order of the entities being culled was dependent on where in this list of lists the entities were. If they were at the top of the list(s), then they were culled. Their position in the list(s) was dependent on where in the chunk they were, in a first-found-first-written-down system.

    This meant that entities that you wanted to stay, such as farm animals, pets and more, could get removed any time you reloaded a chunk. On some modpacks, this was quite troubling as some resources could only be generated by certain entities, or you needed to breed/train/upgrade them and suddenly all that work was deleted.

    The new EntityControl


    I have re-written the logic in which EntityControl culls entities. Instead of the first-found-first-killed system that we have had for quite some time, all of these entities are now sorted by age and persistence.
    Now, most of those entities in the list of lists are copied to, you guessed it, one more list.

    This list is special however. It is sorted. Younger entities first, then older, in ascending order.
    Now, comes a second list. This list contains the remaining entities that aren't in the first list. What decides in which list an entity goes? Whether or not the Entity in question is persistent. This list is sorted by age as well, for reasons that will be mentioned below.

    Persistence is a vanilla mechanic, and is automatically set when you use a nametag on an entity, when you tame a pet, or through a select other few modded interactions, such as Jailor's Safari Nets etc.

    EntityControl now culls entities first from the 'normal' list of entities, removing the younger/newer entities first.
    If however, this list is empty, and the 3x3 chunk area still has too many entities, then EntityControll will start culling from the persistent list, removing the younger/newer entities there.

    How this affects you

    It is now much easier for you, the player, to keep your pets and your farm-animals without having to put them in a pokéball/jar/lasso.
    Whilst there is still a chance for them to be removed, the chance is no longer completely random. The older (in correlation to other nearby entities) your pets/farm-animals are, the smaller said chance of them being removed becomes.

    Let's say that we're on SevTech, and want to make sure that our new baby buffalo stays.
    We just just need to put a name-tag on them, or use something else which sets persistence, and then go kill any other entity in this 3x3 chunk region which is older than our new buffalo.
    As new entities spawn, which will be younger than our buffalo, they'll be put before the buffalo in these 2 lists, essentially pushing our buffalo to the back, and further away from the deadly reach of EntityControl.

    Summary

    Entities are now culled by EntityControl differently than before.
    Instead of haphazardly killing entities as they're given to the plugin, they're now sorted.
    The sorting is done in two stages: first by age, and then by persistence.
    1. Younger/newer entities are killed first
    2. EntityControl continues culling entities based on age in ascending order
    3. If there's no more normal entities to cull, it starts to cull persistent entities
    4. The persistent entities are sorted by age in ascending order as well
    5. Once the 3x3 chunk area has less than a total of n (default 40) entities again, it stops culling.
    6. Any new entities spawning in this 3x3 chunk area (and going over the limit) will be killed first before EntityControl starts looking at the older entities.
     
  2. chaosblad3

    chaosblad3 Very Well-Known Member

    Messages:
    1,701
    Likes Received:
    649
    Local Time:
    9:51 PM
    Could I suggest the addition of a server specific preferential mob weighting step.

    Basically what I mean is on a server like stoneblock/skyfactory where like you said certain resources are acquired from certain animals, there is the risk that you go to spawn a resource chicken/cow/pig/etc but because you didn't realize that your local area was already at the limit, the spawn is prevented (with the item used to spawn it still consumed) as that mob would be the newest/youngest mob in the cull list.

    My suggestion would be to add specific mob type weightings and give certain mobs priority, so that any non-persistent mob that ISN'T a weighted resource mob in the current list is culled FIRST to make room in the local limit to ensure that the new resource mob is able to spawn safely.

    E.g. I would much rather have a relatively young vanilla pig nearby despawn when my freshly bred emerald chicken tries to hatch, than have that egg go to waste because when it tried to spawn it happened to be over the limit and so the poor baby chicken gets immediately yeeted into the void!
     
    Fireforce likes this.
  3. Sandstroem

    Sandstroem Well-Known Member

    Messages:
    1,528
    Likes Received:
    821
    Local Time:
    10:51 PM
    I agree with chaos that server specific settings for specific mobs or even biomes might be a good feature. Take sevtech for example where it would be nice to disable spawn limitations at all in those dark biomes.
     
  4. Matryoshika

    Matryoshika Well-Known Member

    Messages:
    1,193
    Likes Received:
    606
    Local Time:
    10:51 PM

    For now, I'll only be porting the new logic from 1.12 to our 1.10 & 1.7.10 servers, but I've started a discussion amongst the admin-team about the possible pros/cons of further weighting.

    Personally I believe it to be possible to add a simple "entities from [modid] (or a list of registrynames of each entity) overwrites current vanilla entities" function.
    With how common vanilla entities are, this would be plausible without much issues, but a pure "value [entity] over any others" would over time cause only that entity to exist. Naturaly spawning entities would also not work for the same reason.

    As mentioned, I will not be adding this in the direct future, but it may be implemented at a later date.
     
  5. sporefreak

    sporefreak Well-Known Member

    Messages:
    406
    Likes Received:
    140
    Local Time:
    2:51 PM
    While Abit late, I really really appreciate this change.
    The random animal despawns and lack of explanation from anyone I asked about how it worked was the sole reason I have not been active on the mym network.
     
  6. ben_mkiv

    ben_mkiv Well-Known Member

    Messages:
    482
    Likes Received:
    106
    Local Time:
    10:51 PM
    I'm not sure if its related to the EntityControl Plugin or not, but it probably is.

    When spawning bosses like the Botania Gaia it can consume the item while not spawning the boss, and i guess thats because the mob limit was reached.

    So if there isn't a whitelist for certain mobs already thats something that should be considered.
     

Share This Page