- Java 100%
| common | ||
| gradle | ||
| loaders | ||
| packs | ||
| targets | ||
| .gitignore | ||
| build.gradle | ||
| gradle.properties | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE | ||
| README.md | ||
| settings.gradle | ||
ServShred
Simple server side vein miner mod.
One codebase, built for several Minecraft versions on several mod loaders.
| Minecraft | Fabric | Forge | NeoForge | Java |
|---|---|---|---|---|
| 1.20.1 | yes | yes | 17 | |
| 1.21.1 | yes | yes | 21 | |
| 1.21.11 | yes | yes | 21 | |
| 26.1.x | yes | yes | 25 | |
| 26.2 | yes | yes | 25 |
The 26.1 jars are built against 26.1.2 and declare compatibility with all of 26.1.x.
Building
./gradlew collectJars # every target
./gradlew :1.21.1-neoforge:build # a single target
./gradlew :26.2-fabric:runServer # dev server for a single target
./gradlew clean # also empties dist/
Finished jars are copied into the dist/ folder in the root of the repo after every build,
named servshred-<loader>-<modversion>+mc<minecraft>.jar, for example
dist/servshred-neoforge-1.0.14+mc1.21.1.jar.
Gradle downloads the JDK each target needs (17, 21 or 25) through toolchains, so only a JDK that can run Gradle 9.6 has to be installed.
Layout
common/src/main/java the mod itself, identical for every target
common/compat/<name>/java tiny shims for APIs Minecraft renamed (ResourceLocation -> Identifier)
common/data/<layout>/ the vein-mine block tag: "plural" (<= 1.20.x) or "singular" (>= 1.21)
common/resources/ icon
loaders/<loader>/ the entrypoint and metadata file for Fabric, Forge or NeoForge
loaders/neoforge26/ NeoForge 26.1.2+ entrypoint (BreakBlockEvent), picked with loader_sources=
packs/ pack.mcmeta files for the loaders that want one
targets/<minecraft>-<loader>/ one folder per build, just a gradle.properties
gradle/target.gradle the build logic every target shares
dist/ finished jars (created by the build, not committed)
Every target compiles the shared code against its own Minecraft version, using Mojang's names on all loaders. Nothing is shared at the jar level.
Adding a Minecraft version
- Copy the closest folder in
targets/and rename it (<minecraft>-<loader>). - Update the versions in its
gradle.properties. - If that Minecraft version spells something differently, add a folder under
common/compat/and pointcompat=at it.
Settings in gradle.properties for a target:
| Key | Meaning |
|---|---|
loader |
fabric, neoforge or forge |
compat |
folder in common/compat |
data_layout |
plural or singular |
java_version |
JDK the target compiles and runs on |
fabric_remap |
Fabric only: true up to 1.21.11 (obfuscated), false from 26.1 |
minecraft_range, loader_range, platform_range |
version ranges written into the metadata file |
pack_resources |
optional folder holding a pack.mcmeta |
Config
config/servshred.properties is created on first start and documents every option. The old
Fabric-only config file is not read, so settings need to be copied over once.
Behavior notes
- Fabric is told about a break after it happened. Forge and NeoForge only have a "before break" event, so vein mining is queued from it and the first tick checks the origin block really did break before it starts.
- Vein mining runs once per server tick for every active vein, rather than once per dimension tick.
- Dropped items and XP orbs are moved with
setPosinstead ofsnapTo, because that call is named differently in older versions.
Not yet built
This project was written without access to the Gradle plugin and loader repositories, so it has never been compiled. Things most likely to need a tweak on the first build:
- Version numbers in
targets/*/gradle.properties, especially Forge 47.4.0 and Fabric API 0.92.11+1.20.1 (any newer build is fine). Player#hurtinServShred.afterMineon 1.21.11 and 26.x. The original mod calls it on 26.2, but if the compiler wantshurtServer(level, source, amount)it is a one-line change there.- The
addListener(EventPriority, boolean, Class, Consumer)overload on the NeoForge 26.x event bus. If it changed, register the break listener with@SubscribeEvent(priority = LOWEST). pack.mcmetafor NeoForge 1.21.11 and 26.x is omitted. If the vein-mine tag does not load there, add one underpacks/and pointpack_resourcesat it.- Loom and ModDevGradle sharing one Gradle build. If plugin classpath clashes appear, move each loader
into its own build and keep
common/andloaders/as they are.
License
MPL-2.0, see LICENSE.