1

BACKGROUND: I have a minecart rail line that services a few farms which are good distance from spawn (1400 blocks), picking things up and returning them to my storage (sorter). I've done /forceload on all the chunks comprising the minecart line which works great. The line runs continuously no matter where players are. However, I've noticed that the active entity count seems to me to be high (2.3K-2.6K) for just 1-2 players online, and also seeing some "can't keep up" messages on the Spigot 1.18 server. I've done all the server lag prevention I can find online short of using a plugin (e.g. composters on top of hopers, etc.). I think that I need to find a way to reduce the number of active entities in all those forceloaded chunks. Here is a recent Spigot timings paste with just 1 player online: https://www.spigotmc.org/go/timings?url=anitidizit . But still, I could be wrong on the cause of the lag, but the high entity count and related ticks in the timings jumped out at me.

OPTIONS I'M EXPLORING: I could run a command block every so often along the line that kills entities within a certain radius, but with a chunk now delving down to Y=-64, and my rail line being at Y=67, I would need to use a kill radius of something like 131 to get everything, which is quite a ways out on X,Z axis from the rail line, which is not very desirable. I'm also considering trying to ensure there are no dark caves or areas in the chunks to limit mob spawning, but that will be very time intensive given the large area.

QUESTION: I'm wondering if there is a way to either kill only mobs in a certain chunk, from the very top to the very bottom, or some other way to control/reduce the number of mobs along the rail line and in other chunks I've forceloaded (e.g. automated farms). I prefer a command block or configuration option, but I'm not completely opposed to a Spigot plugin.

Thanks.

3
  • You could kill/teleport mobs to void if they aren't within a player's radius and aren't persistent. This way, no mobs that are given items/item tags would be killed by accident. This would be much more flexible since you wouldn't have to type in the coordinates of the chunks somewhere in the code. Would this solution fit your question instead of being in a specific chunk?
    – BunnyMerz
    Dec 17, 2021 at 1:00
  • @BunnyMerz I'm exploring this as an option as it would be the most simple and would meet the desired end goal. It could work, but I want to make sure I don't kill mobs used in farms. I guess I could do a series of very specific kills for each mom type. I'm also looking for a way to do an inventory of active moms so I can get a breakdown of what the 2K+ moms are (or where) to help assess their impact on performance.
    – TimigenX
    Jan 13, 2022 at 15:38
  • Not sure how i didn't think of it but... mobs that are outside the player's range will by default disapear. You probably should look what mobs and where they are. You could deff do this with commands and scoreboards.
    – BunnyMerz
    Jan 14, 2022 at 4:52

1 Answer 1

2

To kill all entities in a certain rectangular area (like a chunk), you could run something like this in a repeat command block:

/execute as @e[type=!minecraft:player,type=!minecraft:minecart,x=<lowerX>,y=-64,z=<lowerZ>,dx=<xSize>,dy=383,dz=<zSize>] run kill @s

To kill all entities that are not player or minecart from x, y, z: (lowerX, -64, lowerZ) to (lowerX + xSize + 1, 320, lowerZ + zSize + 1), that is a rectangular box from bedrock to sky limit.


Additional Info:

You should consider other options as it is not a good practice to use /forceload. consider this options:

  1. Better item transport instead of a line of hoppers.
  2. Local storage system, instead of transporting a long distance.
  3. What is your farm exactly? Maybe optimizing the farm efficiency could decrease the load a lot.
6
  • This looks like it could work and I'll be testing this. One note, you mentioned not using /forceload which seems reasonable given its inevitable hit to performance, but in my use cases I feel need to. I have a gold farm which needed to be good distance from the portals at the "main base" so as not to attach to them, so I'm using a mine cart line to collect. Also, I route mine carts to locations based on a specified armor stand, which has to be loaded in order to be located. Also, to your last question, farms are chicken, gold, iron, sugarcane, and slime, so not too many I think.
    – TimigenX
    Jan 13, 2022 at 15:47
  • Most lag comes from entities, so best approach is to reduce the amount of those, looking at servers like scicraft they afk at a farm for like a few days to get enough resources and then leave that place, and dig a perimeter to remove all other things (like animals, light updates etc.) to eliminate any other source of lag. so I suggest that you don't use all the farms at once, but build an efficient farm and use the one you need. good luck Jan 13, 2022 at 20:27
  • This worked perfectly. Thank you! In case it is of interest, once I have it deployed, I will report on if sufficiently reduces the active entity count.
    – TimigenX
    Jan 15, 2022 at 4:28
  • I'll be happy to hear that Jan 15, 2022 at 20:15
  • This answer did exactly as requested. Since the long rail line servicing the remote chicken and gold farms was a straight line, I was able to use a single command block to kill all entities from top to bottom along it (except players, carts, and chest carts). I thought that would significantly reduce the number of entities, but it did not seem to. (spigotmc.org/go/timings?url=yuzazocusi) I don't think there are more than a couple 100 total entities in the few farms we have (certainly not 2000+), but I will look ways to reduce entities and try what you mentioned. Thank you!
    – TimigenX
    Jan 16, 2022 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .