diff --git a/README.md b/README.md index 638d431..20647c6 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,72 @@ -# Detect AFK Players (and all its first-party add-ons) +# clo4's Minecraft datapacks -A simple way to detect AFK players for vanilla or modded servers, which allows -you to build additional social signalling mechanics and improve the experience -for all players. - -Players are marked as AFK (`afk`) after 3 minutes of without moving the mouse. +Collection of all of my datapacks. These are typically focused on SMP server +administration because that's what I find myself needing more tooling for. -It's easy to integrate with, too! AFK players are tagged as `afk`, and you can -use the `#afk:away` and `#afk:back` function tags to implement your own -functions. - -This is a server utility. I value composability over functionality, preferring -to have less built in to the datapack and allowing you to build the features you -need on top of it. If you don't want announcements, or sleeping, or _whatever_, -you can just pick the features you _do_ want and use them without any issues or -having to edit a complicated mess while trying to remove them from an existing -datapack. Instead, each piece of functionality is self contained and performant. +Keeping everything in the same repository makes it easier to build stuff fast! ## Table of Contents -- [Detect AFK Players (and all its first-party add-ons)](#detect-afk-players-and-all-its-first-party-add-ons) +- [clo4's Minecraft datapacks](#clo4s-minecraft-datapacks) - [Table of Contents](#table-of-contents) - [Datapacks](#datapacks) + - [Pause Day Cycle](#pause-day-cycle) + - [Chickenfix](#chickenfix) - [Detect AFK Players](#detect-afk-players) - - [AFK Sleep: Sleep while players are AFK](#afk-sleep-sleep-while-players-are-afk) - - [AFK Message: Announce status to server](#afk-message-announce-status-to-server) - - [AFK Dim Names: Color names of AFK players](#afk-dim-names-color-names-of-afk-players) - - [Documentation](#documentation) + - [Documentation](#documentation) + - [AFK Sleep](#afk-sleep) + - [AFK Message](#afk-message) + - [AFK Dim Names](#afk-dim-names) - [Contributing](#contributing) ## Datapacks +### Pause Day Cycle + +[View and download on Modrinth](https://modrinth.com/datapack/pause-day-cycle) + +A very lightweight datapack that disables `doDaylightCycle` when nobody is +online or everyone online is tagged as `afk` (see #detect-afk-players). It's +best suited for small to medium sized servers where there are large stretches of +time that nobody will be online, or long periods where players may be AFK (eg. +at a mob grinder overnight). This is to prevent the local difficulty and day +count from becoming excessive and not representative of the amount of time that +players have actually played on the server. + +The following gamerules are affected: + +- `doDaylightCycle` +- `doWeatherCycle` + +The gamerule `mobSpawning` is unaffected to allow mob grinders and automatic +farms to function with nobody present or an AFK player loading the chunk. + +You can hook into the pause and resume events using the `pause_day_cycle:pause` +and `pause_day_cycle:resume` function tags, which will be called whenever the +day cycle pauses or resumes. + +### Chickenfix + +[View and download on Modrinth](https://modrinth.com/datapack/chickenfix) + +A simple but effective brute force fix to chickens suffocating in walls when +they grow up in a cramped, inhumane chicken farm. + +It works by teleporting chickens to the center of the block they're in, on the +tick where they grow into an adult. This prevents them from being shoved into a +wall and suffocating. This is only done if the chicken is withing five blocks of +any entity named exactly `chickenfix`, to prevent normal (humane) chicken farms +from being broken by the same logic that fixes the inhumane ones. + ### Detect AFK Players -[View on Modrinth](https://modrinth.com/datapack/detect-afk) +[View and download on Modrinth](https://modrinth.com/datapack/detect-afk) + +A simple way to detect AFK players for vanilla or modded servers, which allows +you to build additional social signalling mechanics and improve the experience +for all players. + +Players are marked as AFK (`afk`) after 3 minutes of without moving the mouse. The base **afk** datapack implements the AFK detection behavior, acting as a library for other datapacks. Players are treated as AFK after not touching the @@ -43,9 +76,15 @@ This datapack also gives players the `afk` tag when they become AFK, and removes it when they return. This allows you to detect AFK players without having to install any other datapacks, making it very easy to integrate with. -### AFK Sleep: Sleep while players are AFK +#### Documentation + +Information on how to integrate with Detect AFK Players is in +[afk/README.md](./afk/README.md). There are example datapacks below, which also +contain examples of the functionality you can build. + +### AFK Sleep -[View on Modrinth](https://modrinth.com/datapack/afk-sleep) +[View and download on Modrinth](https://modrinth.com/datapack/afk-sleep) Changes the `playersSleepingPercentage` to allow sleeping while there are AFK players on the server. @@ -60,46 +99,32 @@ sleep for a night to pass. | 3 | 2 | 100% | 2 | | 3 | 2 | 50% | 1 | -### AFK Message: Announce status to server +### AFK Message -[View on Modrinth](https://modrinth.com/datapack/afk-message) +[View and download on Modrinth](https://modrinth.com/datapack/afk-message) Using this datapack will announce to all players on the server when someone becomes AFK or returns to the game. -### AFK Dim Names: Color names of AFK players +### AFK Dim Names -[View on Modrinth](https://modrinth.com/datapack/afk-dim-names) +[View and download on Modrinth](https://modrinth.com/datapack/afk-dim-names) Using this datapack colors the names of AFK players gray and moves them to the bottom of the player list. -## Documentation - -You can use the AFK functionality by adding functions to the `#afk:away` and -`#afk:back` function tags. Functions in both tags are called as the player at -the player's position. - -The example below is a very simple datapack that kicks AFK players if they -aren't specatating. - -**kick-afk-players/data/afk/tags/functions/away.json** - -```json -{ "values": ["afk_kick:kick"] } -``` - -**kick-afk-players/data/afk_kick/functions/kick.mcfunction** - -```mcfunction -execute if entity @s[gamemode=!spectator] run kick @s AFK -``` - ## Contributing -As the pack is right now, I don't need anything more from it myself, and I don't -find myself motivated to work on things that I don't need. If you have some -ideas for additional functionality, you're welcome to contribute it! +I value composability over functionality, preferring to have less built in to +datapacks and allowing you to build the features you need on top of it. Each +piece of functionality can be small and performant, and they can be combined +together to create something more complicated without sacrificing on +maintainability or performance. + +I typically only work on what I feel motivated to work on, because this isn't my +job. I just do it for fun and to make my own life easier. But if there's a +feature that you want added, either create an issue for it and I'll take a look +or just contribute it and we'll get it merged and released! If you're on an operating system where bash is available, the build script is executable as `./build.sh`. All the required development tools are included in diff --git a/afk/README.md b/afk/README.md new file mode 100644 index 0000000..c77a02f --- /dev/null +++ b/afk/README.md @@ -0,0 +1,20 @@ +# Documentation + +You can use the AFK functionality by adding functions to the `#afk:away` and +`#afk:back` function tags. Functions in both tags are called as the player at +the player's position. + +The example below is a very simple datapack that kicks AFK players if they +aren't specatating. + +**kick-afk-players/data/afk/tags/functions/away.json** + +```json +{ "values": ["afk_kick:kick"] } +``` + +**kick-afk-players/data/afk_kick/functions/kick.mcfunction** + +```mcfunction +execute if entity @s[gamemode=!spectator] run kick @s AFK +``` diff --git a/chickenfix/README.md b/chickenfix/README.md deleted file mode 100644 index 0f37f94..0000000 --- a/chickenfix/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# chickenfix - -Simple (but performant) brute-force fix to chickens suffocating to death when -they grow up, such as in fox-based chicken farms. - -This datapack "fixes" the problem by centering the chickens on the block when -they grow up, but only if they're within five blocks of an entity named -`chickenfix`. - -## Why isn't the fix applied globally? - -This solution would cause problems for normal chicken farms due to fence -hitboxes, and it's also entirely unnecessary for chickens where you don't really -care if they suffocate or not. diff --git a/pause-day-cycle/README.md b/pause-day-cycle/README.md deleted file mode 100644 index 8c5e1aa..0000000 --- a/pause-day-cycle/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Pause Day Cycle - -Lightweight Minecraft datapack to disable `doDaylightCycle` when nobody is -actively playing. It's best suited for small to medium sized 24/7 dedicated -servers where there are times nobody is playing -- otherwise, if the server is -running all the time, the day count becomes excessive very quickly. - -When nobody is online or all online players are tagged as `afk` (see -[clo4/afk-datapack](https://github.com/clo4/afk-datapack)) the following -gamerules will be set to false: - -- `doDaylightCycle` -- `doWeatherCycle` - -`mobSpawning` isn't changed because it allows automatic farms to function with -nobody present. - -You can also hook into it using the tags `pause_day_cycle:pause` and -`pause_day_cycle:resume`: - -###### announce/data/pause_day_cycle/tags/functions/pause.json - -```json -{ "values": "announce:pause" } -``` - -###### announce/data/announce/functions/pause.mcfunction - -```mcfunction -say Day cycle has been paused because nobody's playing -```