A high-performance, fully server-side capable gambling and economy-sink mod for Minecraft Fabric 1.21.1. Designed with a strict focus on Type Safety, efficient data structures, and a data-driven approach.
This mod is built natively in Kotlin (fabric-language-kotlin) and utilizes modern software engineering patterns to ensure server stability:
The SlotMachineEngine does not rely on hardcoded, linear iterations for probability. Instead, it uses a pre-calculated cumulative weight algorithm mapped to a java.util.TreeMap.
-
Efficiency: Roll evaluations are performed using
ceilingEntry(), ensuring an$O(\log n)$ time complexity for probability lookups, completely eliminating GC (Garbage Collection) pressure during consecutive slot rolls.
The LittleAnimalsEngine handles server-wide lottery bets. To prevent data loss when a player logs off before a draw:
- Implements a custom
LittleAnimalsStateextending Minecraft'sPersistentState. - Offline bets are safely serialized to NBT data and saved directly to the world's
data/folder. - Uses the
ServerPlayConnectionEvents.JOINevent to execute lazy-evaluation payouts the exact tick a winning player reconnects.
To prevent BootstrapExceptions during server initialization, all Minecraft native objects (like SoundEvent and ParticleType) are stored as String identifiers in the configuration state. They are strictly evaluated at runtime using Identifier.of() with Safe Casts (as?) and built-in fallbacks to prevent crashes from invalid configuration strings.
To compile this mod yourself, you will need Java 21 and Git installed on your system.
- Clone the repository:
git clone https://github.com/CarlosMi11/letsGoGambling.git cd letsgogambling-fabric - Build the project using the Gradle wrapper:
- Windows:
gradlew build - Linux/Mac:
./gradlew build
- Windows:
- The compiled
.jarfile will be located in thebuild/libs/directory.
- [In Progress] JSON Persistence: Currently, the configuration lives in memory via data classes (
CONFIG.kt). We are actively migrating this to a physical.jsonfile structure usingkotlinx.serializationfor hot-reloading capabilities. - [Planned] YACL Integration: Future support for Yet Another Config Lib for an in-game UI.
Pull requests are welcome! Please ensure your code follows standard Kotlin conventions and does not break the
This mod provides virtual economy mechanics. The source code is provided as-is. The developer assumes no legal responsibility if server administrators violate the Minecraft Commercial Usage Guidelines by monetizing the in-game currency (Utilis.CURRENCY) with real-world money. Do not use this mod for real-money gambling.