Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Before a release, `./gradlew releaseChangelog` turns *Unreleased* into the relea

### Added

- Serial Port addon, with the recipe from 1.12.2 (quartz and I/O buses): lets computers use turret bases of tiers 2–4 (tier 5 bases accept them without it)
- Computer control: `setComputerControl(true)` stops a base's turrets from targeting on their own, so a computer aims and fires them (`isComputerControl` tells whether it is on)
- CC: Tweaked support: turret bases are the peripheral `turret_base`, with the computer commands of the Serial Port addon.
- Turrets on a base with a damage amp addon show a small red light on each corner of their base plate
- Config sections `upgrades` and `addons` switch each upgrade and addon off: it loses its recipe and does nothing in a machine, which shows it with a red slot frame, a "no" symbol over the icon and a red tooltip line
- Range falloff (#539): turrets deal full damage up to a share of their range (`optimalRange`), then less down to `falloffDamage` at the end of the range; configurable per turret, off for the grenade, rocket, railgun and effect turrets
Expand Down
6 changes: 5 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Core gameplay:
Jar-in-jar it (approved).
- **Jade** (optional integration, `compat/jade/` for the server half and `client/compat/jade/` for the tooltips, registered through the `jade` entrypoint on Fabric and `@WailaPlugin` on NeoForge).
Compile-only (`modCompileOnly`, Modrinth maven), never bundled and never required at runtime.
- **CC: Tweaked** (`cc.tweaked`, from `maven.squiddev.cc`), on both nodes (approved by the user on 2026-11-27): compile-only against its `-api` jar, never bundled, an optional dependency in the loader metadata (`suggests` on Fabric, an optional dependency in `neoforge.mods.toml`); the full mod is in the dev runs (`modLocalRuntime` / `localRuntime`), on the game test servers and in `runenv`.
Gated on `cctweaked_version` in `versions/<node>/gradle.properties` (1.117.1, the only version for 1.21.11; its artifacts are named `fabric` and `forge` on that maven, the NeoForge jar is the `-forge` one); the code is loaded behind `isModLoaded("computercraft")`.
- **NeoForge** 21.11.x, built with **ModDevGradle** (approved by the user; build-time only).
On NeoForge, the Fabric-only APIs above are replaced by NeoForge's own (capabilities, events, payload registration); see §4 "Loaders".
- **OpenModularCore** (the team's shared core, `../../OpenModularCore`, module `omt-core` from JitPack, approved by the user on 2026-11-16): the game rules (`omtteam.openmodularturrets.core`), the same on every Minecraft version; compile-only, its classes are bundled into the mod's jar (see "Core Game Logic Source").
Expand Down Expand Up @@ -231,7 +233,9 @@ The § numbers and headings of the moved sections are kept, so references such a

- Every variant (base tier, ammo type, upgrade, addon) is an **individual registered block/item** with a lowercase snake_case ID.
`docs/id-mapping.md` maps the 1.12.2 IDs to the current ones.
- OpenComputers / ComputerCraft integration is **out of scope for now** (ask before adding).
- Computers: the loader-free base is present: the commands in `core/computer` (`BaseComputerCommands`, a port of 1.12.2's, plus computer control), `TurretBaseBlockEntity.getTurret(face)`, `blockentity.base.BaseComputerTurrets`, `TurretBlockEntity.setYawPitch` / `setAutoFire` / `forceShot`, the Serial Port addon (`addon_serial_port`, 1.12.2 recipe and texture), `ComputerControlGameTests`.
**CC: Tweaked** is supported on both nodes (decided by the user, 2026-11-27): `compat/computercraft/TurretBasePeripheral` (one loader-free class, the peripheral `turret_base`, the same methods as the 1.12.2 callbacks) reuses `BaseComputerCommands`; only its registration is per loader (`platform/<loader>/computercraft`); `ComputerCraftGameTests` tests it.
OpenComputers (1.21.1 only) is **not present** here (ask before adding).

### Designing APIs

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The other Minecraft versions have their own branches:
- **Turret API for other mods:** add turrets with their own weapons, ammo, models and custom hit logic; see [docs/turret-api.md](docs/turret-api.md)
- Uses **Team Reborn Energy** on Fabric, so it works with energy from other Fabric tech mods; the NeoForge build uses its energy capability (FE) instead
- Optional **Jade** support for turret bases and turrets, on both loaders
- Optional **CC: Tweaked** support (both loaders): turret bases are the peripheral `turret_base`, with the same functions as 1.12.2's computer callbacks, with a Serial Port addon or on tier 5
- **Computer control** base: turret bases with a Serial Port addon (or on tier 5) accept computer commands, and a computer can aim and fire the turrets itself

## Requirements

Expand Down
16 changes: 16 additions & 0 deletions build.fabric.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ tasks.withType<net.fabricmc.loom.task.AbstractRunTask>().configureEach {
doFirst { clientResources.get().asFile.mkdirs() }
}

// CC: Tweaked comes only from its own maven
repositories {
exclusiveContent {
forRepository { maven("https://maven.squiddev.cc") { name = "CC-Tweaked" } }
filter { includeGroup("cc.tweaked") }
}
}

dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings(loom.officialMojangMappings())
Expand All @@ -79,6 +87,14 @@ dependencies {
// Jade tooltips (optional, not bundled: the mod only registers the plugin when Jade is installed)
modCompileOnly("maven.modrinth:jade:${property("jade_version")}")

// CC: Tweaked (optional, not bundled: the peripheral in compat/computercraft is only registered when it is
// installed): its API compile-only, the full mod in the dev runs and on the game test server for the peripheral test
findProperty("cctweaked_version")?.let { cc ->
val mc = property("minecraft_version")
modCompileOnly("cc.tweaked:cc-tweaked-$mc-fabric-api:$cc")
modLocalRuntime("cc.tweaked:cc-tweaked-$mc-fabric:$cc")
}

// Architecture rules (src/test/.../architecture): they read the compiled main and client classes
testImplementation("com.tngtech.archunit:archunit-junit5:${property("archunit_version")}")
testRuntimeOnly(sourceSets["client"].output)
Expand Down
19 changes: 19 additions & 0 deletions build.neoforge.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ configurations.runtimeClasspath { extendsFrom(localRuntime) }
// Not on the GameTest server: Jade there sends its ping to the vanilla mock players of the tests, which NeoForge
// refuses (no negotiated channels).

// CC: Tweaked comes only from its own maven
repositories {
exclusiveContent {
forRepository { maven("https://maven.squiddev.cc") { name = "CC-Tweaked" } }
filter { includeGroup("cc.tweaked") }
}
}

dependencies {
// OMLib (git submodule omlib, built by :buildOmlib): a mod of its own, jar-in-jar. The client and game test source
// sets only see main's classes, not its dependencies.
Expand All @@ -91,6 +99,17 @@ dependencies {
// Jade plugin (compat/jade, client/compat/jade): optional, not bundled; present in dev runs to try it
compileOnly("maven.modrinth:jade:${property("jade_version")}")
localRuntime("maven.modrinth:jade:${property("jade_version")}")

// CC: Tweaked: the turret base peripheral (compat/computercraft, platform/neoforge/computercraft) compiles against
// its API jars, never bundled, only used when CC: Tweaked is installed; the full mod is in the dev runs and on the
// GameTest server for its test (its artifacts are named -forge on the CC maven).
(findProperty("cctweaked_version") as String?)?.let { cc ->
val mc = property("minecraft_version")
compileOnly("cc.tweaked:cc-tweaked-$mc-forge-api:$cc")
localRuntime("cc.tweaked:cc-tweaked-$mc-forge:$cc")
"gametestCompileOnly"("cc.tweaked:cc-tweaked-$mc-forge-api:$cc")
"gametestRuntimeOnly"("cc.tweaked:cc-tweaked-$mc-forge:$cc")
}
}
// The client half of the Jade plugin (client/compat/jade) compiles against it too, as with Loom's client source set
configurations.named("clientCompileOnly") { extendsFrom(configurations.compileOnly.get()) }
Expand Down
22 changes: 20 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This is the only place where the two meet, and the reason the core can be tested
| `item.ItemSlot` | `blockentity.base.ContainerItemSlot` | one inventory slot: count, what the item is (ammo, upgrade, addon, fuel), extract |
| `target.TargetEntity` | `blockentity.base.LivingTargetEntity` | one living entity: position and eyes (in the base's coordinates), health, armor, category, owner (pets) |
| `settings.LogicSettings` | `config.ConfigLogicSettings` | config values (turret stats, base tiers, entity lists) |
| `computer.ComputerTurrets` | `blockentity.base.BaseComputerTurrets` | the turrets on a base's faces: aim, auto fire, forced shot |
| `security.SecurityEnvironment` (OMLib) | `security.LevelSecurityEnvironment` (OMLib, with `OMTOwnershipSettings`) | scoreboard teams, operator rights |

All positions the core sees are in the base's coordinates.
Expand Down Expand Up @@ -106,6 +107,7 @@ Packages below `omtteam.openmodularturrets` (main):
| `core.target` | `TargetSelector`: who is a valid target and who is the best one |
| `core.security` | `DamageRules` (who turret damage may hit); the owner, trusted players and access levels (`TrustManager`) are in OMLib |
| `core.generator`, `core.card` | generator burning, the memory card's copy rules for a base's settings (`BaseCardRules`; the card data and the trust list copy rules are OMLib's `core.card`, camouflage permissions OMLib's `core.camo`, machine mode and targeting settings OMLib's `core.machine`) |
| `core.computer` | `BaseComputerCommands`: the commands a computer may send to a turret base (1.12.2's, plus computer control), with the interfaces it needs from the game |
| `core.item`, `core.settings`, `core.world` | upgrade/addon types, config value types, the world interfaces above |
| `core.storage` | `SlotCapacity`: how much an ammo or fuel slot holds with the attached inventory expanders; `AmmoSort`: the order of the sort button (`TurretBaseInventory.sortAmmo`) |
| `api`, `api.weapon` | public turret API for other mods; the built-in turrets use it too |
Expand All @@ -118,8 +120,8 @@ Packages below `omtteam.openmodularturrets` (main):
| `network` | packets: client→server requests (always re-validated) and server→client sync (OMLib's `ConfigSync` sends the configs on join) |
| `config` | the JSON config: fields, comments, ranges, migration, the server's config on clients |
| `security`, `camo` | the mod's ownership rules (`OMTOwnershipSettings`); the trust lists' Minecraft side (NBT, player lookup) is in OMLib, and camouflage rules |
| `compat` | the porting helpers that keep call sites identical on the version branches (`VersionCompat`, `CompatBlockEntity`, networking, menus; `compat.nbt.NbtCompat` for all NBT reads and `compat.block.BlockCompat` depend on Minecraft only, so any package may use them), small loader differences (`//? if fabric` / `neoforge`), Jade (server half here, tooltips in `client.compat.jade`), and the contraption pose hooks (`SubLevelCompat`, `client.compat.ClientSubLevelCompat`; always the identity pose here, as there is no Sable) |
| `platform` | the loader services shared code calls (`Platform`: `LoaderInfo`, `Fuel`, `Network`, `Menus`, `Energy`); `platform.fabric` / `platform.neoforge` hold the entrypoints, the implementations and the energy/item adapters, and only compile for their loader |
| `compat` | the porting helpers that keep call sites identical on the version branches (`VersionCompat`, `CompatBlockEntity`, networking, menus; `compat.nbt.NbtCompat` for all NBT reads and `compat.block.BlockCompat` depend on Minecraft only, so any package may use them), small loader differences (`//? if fabric` / `neoforge`), Jade (server half here, tooltips in `client.compat.jade`), the CC: Tweaked peripheral (`compat.computercraft`), and the contraption pose hooks (`SubLevelCompat`, `client.compat.ClientSubLevelCompat`; always the identity pose here, as there is no Sable) |
| `platform` | the loader services shared code calls (`Platform`: `LoaderInfo`, `Fuel`, `Network`, `Menus`, `Energy`); `platform.fabric` / `platform.neoforge` hold the entrypoints, the implementations and the energy/item adapters, and only compile for their loader; `platform.<loader>.computercraft` registers the CC: Tweaked peripheral |
| `datagen` | recipes, loot tables, tags, damage types (Fabric only; the NeoForge build converts the Fabric output) |

`./gradlew dependencyMap` draws these packages and every import between them as an interactive page.
Expand Down Expand Up @@ -216,6 +218,22 @@ The base learns of its expanders through `Neighbour.Expanders` in `TurretBaseLog
The stacks above one stack are OMLib's large stacks: `TurretBaseInventory` and `FuelContainer` implement `LargeStackContainer` (also on the client, with the bonus stacks synced as menu data), the menus extend `LargeStackMenu` with `LargeStackSlot`s, the screens `LargeStackScreen`, and `VersionCompat.saveItems` saves the counts.
Removing an expander leaves larger stacks in the slots; they only cannot grow until they are below the new limit.

### Computers

A computer reaches a turret base through these layers; this version has all three, for CC: Tweaked:

1. `core.computer.BaseComputerCommands` holds the commands (1.12.2's, ported with their names, arguments and messages): plain Java values in, an `Object[]` result out, a wrong argument gives an error message, not an exception.
Every command first asks `TurretBaseLogic.acceptsComputers()` (tier 5, or a Serial Port addon); trust changes act as the base's owner through its `TrustManager`, which saves and syncs.
The turrets are reached through `ComputerTurrets` (`blockentity.base.BaseComputerTurrets` over the turrets mounted on the base), player names through `PlayerNames` (the integration provides it).
2. Computer control (`setComputerControl`, `TurretBaseLogic.isComputerControlled()`, saved with the base): the base drops its targets and searches none, and its turrets stay deployed and fire only when told to (`TurretBlockEntity.setYawPitch`, `setAutoFire`, `forceShot`; forced shots ignore the turn rate).
Control and auto fire only apply while the base accepts computers (tier 5 or a Serial Port): a base that lost its Serial Port targets on its own again, since no computer could switch control off.
3. The mod integration: **CC: Tweaked** (both loaders, `compat.computercraft`).
`TurretBasePeripheral` is the peripheral `turret_base`, one class for both loaders; its `@LuaFunction(mainThread = true)` methods have the names of 1.12.2's callbacks (`changeAccessLevel` and `forceShootAllTurrets` as well) and call the commands, so CC runs them on the server thread.
Only the registration is per loader, and only when `computercraft` is loaded: `platform.fabric.computercraft.FabricComputerCraft` (`PeripheralLookup`) and `platform.neoforge.computercraft.NeoForgeComputerCraft` (`PeripheralCapability`, in `RegisterCapabilitiesEvent`).
`ServerPlayerNames` (the `PlayerNames` of the peripheral) reads the server's `usercache.json` itself, as the profile cache has no lookup that never asks Mojang.
CC: Tweaked is compile-only (its API from `maven.squiddev.cc`, never bundled), and the full mod runs in the dev runs and on the game test servers (`cctweaked_version` in `versions/<node>/gradle.properties`).
OpenComputers has no integration here (it exists for NeoForge 1.21.1 only).

## How to add …

### A turret
Expand Down
2 changes: 1 addition & 1 deletion docs/id-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The inventory expanders of 4.x (`inventory_expander_tier_one` to `_three`, the m
| `openmodularturrets:addon_meta` | 2 | *(not ported: potentia converter, no function in oldmod)* |
| `openmodularturrets:addon_meta` | 3 | `openmodularturrets:addon_recycler` |
| `openmodularturrets:addon_meta` | 4 | `openmodularturrets:addon_redstone_reactor` |
| `openmodularturrets:addon_meta` | 5 | *(not ported: serial port, computer integration out of scope)* |
| `openmodularturrets:addon_meta` | 5 | `openmodularturrets:addon_serial_port` |
| `openmodularturrets:addon_meta` | 6 | `openmodularturrets:addon_solar_panel` |
| `openmodularturrets:addon_meta` | 7 | `openmodularturrets:addon_fake_drops` |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ private static void appendAddon(AddonItem item, List<Component> lines) {
lines.add(flavour("addon.fakedrops.flavour"));
}
case SERIAL_PORT -> {
lines.add(text("addon.serial.a"));
lines.add(text("addon.serial.b"));
lines.add(Component.empty());
lines.add(flavour("addon.serial.flavour"));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/gametest/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The test mod's loader entrypoints (`gametest/platform/<loader>`) run its registr
A local test run keeps its config file, and the merge keeps old values of addon turrets: delete `versions/1.21.11-fabric/build/run/gameTest/config/openmodularturrets*` and `versions/1.21.11-neoforge/run/config/openmodularturrets*` after a default changes.
- `BaseGuiGameTests` clicks a base through `ServerPlayerGameMode#useItemOn` (the real server path, including the loader's block-use event) and checks that the menu opens for the owner only.
The loaders' `FakePlayer`s refuse to open menus, so the test uses `GuiTestPlayer`, a small subclass that opens them without sending a packet (NeoForge opens block menus through the two-argument `openMenu`, which it overrides too); `CamoMenuGameTests` uses it for the camouflage menu and its "Back" to the base GUI.
- `ComputerCraftGameTests` asks the loader's own peripheral lookup (Fabric `PeripheralLookup`, NeoForge `PeripheralCapability`) for the base, as a computer or wired modem does, and calls the `turret_base` methods with arguments as CC passes them; CC: Tweaked is on both test servers (`cctweaked_version`), and the commands themselves are tested in `ComputerControlGameTests`.
- `TrustListGameTests`, `CamoMenuGameTests` and the light tests in `CamoGameTests` call OMLib's packet handlers (`TrustPacketHandler`, `CamoPacketHandler`) directly with fake players placed next to the block, as the server does on a packet, and check permission, reach and the access level steps.
Fake players are not on the server's player list, so the test that adds an online player by name puts one there for the (synchronous) request only (`TrustListGameTests.online`), on Fabric only: NeoForge returns a read-only view of the list, and vanilla's mock players would log in for real.
Names of players who are not online go to the server's name cache: the test server has one (offline mode, so the name's offline UUID).
Expand Down
Loading