diff --git a/CHANGELOG.md b/CHANGELOG.md index 617fd55..45ce151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Before a release, `./gradlew releaseChangelog` turns *Unreleased* into the relea ## [Unreleased] +### Added + +- NEEPMeat compatibility (Fabric 1.20.1): vascular conduits power electric lights (1 eJ = 1 E); a full electric light takes no power from the network + ### Fixed - The grow light no longer grows its crop every tick when its growth chance is configured extremely small diff --git a/CLAUDE.md b/CLAUDE.md index 73f7061..c1584b6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,6 +42,8 @@ Core gameplay: The tooltip half is in the client source set because Jade's tooltip classes are client classes. Jade creates every plugin it finds on dedicated servers too, where the client class cannot be loaded (Fabric refuses it), so `OMLJadeClientPlugin` is not registered with Jade: `OMLJadePlugin.registerClient`, which Jade calls only on a client, creates it by name and forwards to it (fixed on 2026-10-27: before, dedicated servers with Jade logged errors). The Forge `client` source set gets Jade through `clientCompileOnly` extending `compileOnly`. +- **NEEPMeat** (Fabric, Modrinth `maven.modrinth:neepmeat`, version in `versions/1.20.1-fabric/gradle.properties`; requested by the user on 2026-11-04): its vascular network charges the electric lights through OMLib (`platform/fabric/FabricNeepMeatPower`, registered by `FabricBlockLookups` when NEEPMeat is loaded; 1 eJ = 1 E, a full buffer takes nothing), so the mod has no code of its own for it. + Never bundled (`suggests` in `fabric.mod.json`); `modCompileOnly` for the game test `gametest/platform/fabric/NeepMeatGameTest`, and `modLocalRuntime` with the mods nested in its jar (Loom leaves them out of its remapped copy; OMLib's `nestedModJars`) and **GeckoLib**, which it requires, for the dev runs and the game test server. - **Forge** 47.x, built with the legacy variant of ModDevGradle (`net.neoforged.moddev.legacyforge`; build-time only, approved by the user), requested by the user. On Forge, the Fabric-only APIs above are replaced by Forge's own (capabilities, events, event network channels); see ยง4 "Loaders" and "Forge 1.20.1". - Build and test tools only, never in the jar (approved by the user, as in OMT): **ArchUnit** (test dependency), **JaCoCo**, **PIT** (plain `JavaExec`, no Gradle plugin) and **PMD**; versions in `gradle.properties`. diff --git a/README.md b/README.md index b74014a..3ff32b3 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,11 @@ On a server, the server's settings are sent to the players. With [Jade](https://modrinth.com/mod/jade) installed, looking at a light shows its mode and whether it is inverted. Jade is not required. +### Optional: NEEPMeat + +On Fabric, [NEEPMeat](https://modrinth.com/mod/neepmeat)'s vascular conduits power the electric lights, 1 eJ per energy unit. +A full light takes no power from the network. + ## Requirements - Fabric: Minecraft 1.20.1 (Java 17), with [Fabric Loader](https://fabricmc.net/) and [Fabric API](https://modrinth.com/mod/fabric-api) diff --git a/build.fabric.gradle.kts b/build.fabric.gradle.kts index 974b828..6cccf65 100644 --- a/build.fabric.gradle.kts +++ b/build.fabric.gradle.kts @@ -67,6 +67,25 @@ dependencies { modCompileOnly("maven.modrinth:jade:${property("jade_version")}") modLocalRuntime("maven.modrinth:jade:${property("jade_version")}") + // NEEPMeat: OMLib's FabricNeepMeatPower lets its vascular network charge the electric lights. Not bundled, the mod + // needs nothing of it; NEEPMeat (with the mods nested in its jar, which Loom leaves out of its remapped copy: + // nestedModJars in omlib/build-logic) and GeckoLib (which it requires, also with the library nested in its jar) are + // in the dev runs and on the game test server, where gametest/platform/fabric/NeepMeatGameTest checks a floodlight + val neepmeat = "maven.modrinth:neepmeat:${property("neepmeat_version")}" + modCompileOnly(neepmeat) + modLocalRuntime(neepmeat) + // resolved lazily, when Loom resolves modLocalRuntime (earlier, it would use the repository before Loom sets it up) + val geckolib = "maven.modrinth:geckolib:${property("geckolib_version")}" + modLocalRuntime(geckolib) + // GeckoLib nests a library too (mclib; without it the client's resource reload fails) + val nested = layout.buildDirectory.dir("nested-mods") + modLocalRuntime(files(Callable { + listOf(neepmeat, geckolib).flatMap { notation -> + val jar = configurations.detachedConfiguration(dependencies.create(notation)).apply { isTransitive = false }.singleFile + nestedModJars(jar, nested.get().asFile) + } + })) + // 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) diff --git a/docs/architecture.md b/docs/architecture.md index e09f258..2e04033 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -207,6 +207,7 @@ The numbers are in `core.formula` (`EnergyCost`, `CarbonFuel`, `GrowChance`). Outside access goes through the loader; the adapters are all OMLib's: - Energy: `core.energy.EnergyAccess`, exposed as Team Reborn Energy on Fabric (`FabricEnergyStorages`) and as an FE capability on Forge (`ForgeEnergyHandler`). + On Fabric with NEEPMeat installed, OMLib also makes the lights sinks of its vascular network (`FabricNeepMeatPower`, 1 eJ = 1 E). Only inserting is possible; there is no extraction. - Items: `inventory.ItemAccess.insertOnly`, exposed as `ItemStorage.SIDED` on Fabric (`FabricItemStorages`) and as `IItemHandler` on Forge (`ForgeItemHandler`). - Battery slot and fuel values: `platform.Energy` and `platform.Fuel`. diff --git a/src/gametest/java/omtteam/openmodularlighting/gametest/platform/fabric/NeepMeatGameTest.java b/src/gametest/java/omtteam/openmodularlighting/gametest/platform/fabric/NeepMeatGameTest.java new file mode 100644 index 0000000..fbc4588 --- /dev/null +++ b/src/gametest/java/omtteam/openmodularlighting/gametest/platform/fabric/NeepMeatGameTest.java @@ -0,0 +1,69 @@ +package omtteam.openmodularlighting.gametest.platform.fabric; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import omtteam.omlib.core.energy.EnergyStore; +import omtteam.openmodularlighting.block.FloodlightBlock; +import omtteam.openmodularlighting.blockentity.ElectricFloodlightBlockEntity; +import omtteam.openmodularlighting.gametest.OMLGameTests; +import omtteam.openmodularlighting.registry.ModBlocks; + +/** + * NEEPMeat (Fabric): its vascular network charges an electric floodlight at 1 eJ = 1 E (OMLib's + * {@code FabricNeepMeatPower}; the sink's rules are tested in OpenModularTurrets). + */ +@SuppressWarnings("unused") +public class NeepMeatGameTest implements OMLGameTests { + private static final BlockPos EMITTER = new BlockPos(1, 1, 3); + private static final BlockPos CONDUIT = EMITTER.east(); + private static final BlockPos LIGHT = CONDUIT.east(); + /** Power of the emitter, eJ per tick. */ + private static final int EMITTER_POWER = 1000; + + /** + * Power emitter, vascular conduit, electric floodlight (off, so it uses nothing): the conduit finds the light as a + * sink when placed, and the light is charged with the emitter's whole output, in whole ticks of it. + */ + @GameTest(template = EMPTY_STRUCTURE, timeoutTicks = 200) + public void vascularNetworkChargesAFloodlight(GameTestHelper helper) { + helper.setBlock(EMITTER, block("power_emitter")); + // its saved power (the block entity's class extends one of a library nested in NEEPMeat's jar, not on the + // compile classpath) + CompoundTag power = new CompoundTag(); + power.putInt("power", EMITTER_POWER); + helper.getBlockEntity(EMITTER).load(power); + helper.setBlock(LIGHT, ModBlocks.ELECTRIC_FLOODLIGHT.defaultBlockState().setValue(FloodlightBlock.FACING, Direction.UP)); + EnergyStore energy = ((ElectricFloodlightBlockEntity) helper.getBlockEntity(LIGHT)).getEnergyStore(); + placeAsPlayer(helper, CONDUIT, block("vascular_conduit")); + helper.succeedWhen(() -> { + long amount = energy.getAmount(); + helper.assertTrue(amount >= EMITTER_POWER * 20L, "The floodlight holds only " + amount + " E"); + helper.assertTrue(amount % EMITTER_POWER == 0, + "The floodlight holds " + amount + " E, not whole ticks of " + EMITTER_POWER + " eJ"); + helper.setBlock(CONDUIT, Blocks.AIR); + helper.setBlock(EMITTER, Blocks.AIR); + helper.setBlock(LIGHT, Blocks.AIR); + }); + } + + private static Block block(String id) { + return BuiltInRegistries.BLOCK.get(new ResourceLocation("neepmeat", id)); + } + + /** Places a block like a player does: its state from its neighbours, then its placement callback. */ + private static void placeAsPlayer(GameTestHelper helper, BlockPos pos, Block block) { + BlockPos absolute = helper.absolutePos(pos); + BlockState state = Block.updateFromNeighbourShapes(block.defaultBlockState(), helper.getLevel(), absolute); + helper.getLevel().setBlockAndUpdate(absolute, state); + block.setPlacedBy(helper.getLevel(), absolute, state, null, ItemStack.EMPTY); + } +} diff --git a/src/gametest/resources/fabric.mod.json b/src/gametest/resources/fabric.mod.json index 998c229..30786bb 100644 --- a/src/gametest/resources/fabric.mod.json +++ b/src/gametest/resources/fabric.mod.json @@ -17,6 +17,7 @@ "omtteam.openmodularlighting.gametest.UvFloodlightGameTest", "omtteam.openmodularlighting.gametest.GrowLightGameTest", "omtteam.openmodularlighting.gametest.JadeTooltipGameTest", + "omtteam.openmodularlighting.gametest.platform.fabric.NeepMeatGameTest", "omtteam.openmodularlighting.gametest.CamoGameTest" ] }, diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4bce6aa..967e91a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -37,6 +37,7 @@ "omlib": ">=${omlib_version}" }, "suggests": { - "jade": "*" + "jade": "*", + "neepmeat": "*" } } diff --git a/versions/1.20.1-fabric/gradle.properties b/versions/1.20.1-fabric/gradle.properties index af20882..70f3255 100644 --- a/versions/1.20.1-fabric/gradle.properties +++ b/versions/1.20.1-fabric/gradle.properties @@ -4,3 +4,7 @@ fabric_api_version=0.92.12+1.20.1 java_version=17 team_reborn_energy_version=3.0.0 jade_version=11.13.3+fabric +# NEEPMeat (Modrinth): its vascular network charges the electric lights (OMLib); in the dev runs and +# on the game test server with GeckoLib, which it requires (4.8.4 Fabric) +neepmeat_version=0.34.0-beta+1.20.1 +geckolib_version=SD2lOScS