carpetmod112 icon indicating copy to clipboard operation
carpetmod112 copied to clipboard

Added lifetime tracker

Open Fallen-Breath opened this issue 4 years ago • 6 comments

Ported from Carpet TIS Addition v1.20.0, code modified from TISCarpet13

Doc: https://github.com/TISUnion/TISCarpet113/blob/TIS-Server/docs/Features.md#lifetime

/lifetime tracking [start|stop|restart|realtime]
/lifetime filter <entity_type> [set <selector>|clear]
/lifetime <entity_type> [life_time|spawning|removal [realtime]]

Codes

All related classes of lifetime tracker are in package carpet.commands.lifetime

See the change files for more details

Carpet

  • Added rule commandLifeTime with default value true
  • Added /lifetime command
  • Added lifetime tracker initializing hook at carpet.CarpetServer#onLoadAllWorlds
  • Ported method c in Messanger class for easier porting

Minecraft

All modification to the minecraft codes are commented with // CM lifetime tracker

  • Created methods in WorldServer and Entity for the tracker
  • Added method hooks at tons of places where entity gets created or removed
  • Make some private stuffs in EntitySelector public for /lifetime filter sub command

Issue

Due to mob being able to spawn outside of the spawning sphere, mobs with DESPAWN_IMMEDIATELY removal reason might spam in the statistic. It can be fixed with rule optimizedDespawnRange enabled

Showcase

image

image

image

image

Fallen-Breath avatar Jun 21 '21 11:06 Fallen-Breath

My goodness that's a lot of code! Before I start reviewing it properly, can you reindent your added files with 4 spaces rather than tabs?

Earthcomputer avatar Jun 21 '21 17:06 Earthcomputer

My goodness that's a lot of code! Before I start reviewing it properly, can you reindent your added files with 4 spaces rather than tabs?

Ahhh right I forgot that, one second

Fallen-Breath avatar Jun 21 '21 17:06 Fallen-Breath

done, btw if you search tab character in the carpet package there are some mixing tabs tho xd

Fallen-Breath avatar Jun 21 '21 17:06 Fallen-Breath

I haven't started reviewing it yet as well, but one simple thoguth so far. I'm not sure the trackers should be under the commands packet but rather under utls/helpers or just its own space. any thougths on that @Earthcomputer ?

kerbaras avatar Jul 13 '21 04:07 kerbaras

Yeah it should, commands is only for the interface with the user

Earthcomputer avatar Jul 15 '21 10:07 Earthcomputer

Now all lifetime tracker stuffs are moved to the helpers package. I also finished the filter support for the tracker and updated the pr description

Fallen-Breath avatar Oct 26 '21 04:10 Fallen-Breath