diff --git a/CHANGELOG.md b/CHANGELOG.md index b664e6fa..2fd6f4e9 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 turret bases (1 eJ = 1 E); a full turret base takes no power from the network + ### Changed - Config: `bases.allowContraptionMovement` is deprecated on Minecraft 1.20.1; it never had an effect here, as no contraption mod (Create, Create Aeronautics) is supported on this version diff --git a/CLAUDE.md b/CLAUDE.md index 3e794250..8aa92e40 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -38,6 +38,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 Forge). Compile-only (`modCompileOnly`, Modrinth maven), never bundled and never required at runtime. +- **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 turret bases 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/NeepMeatGameTests`, 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`, same artifact and version as `moddev`; build-time only), requested by the user. On Forge, the Fabric-only APIs are replaced by Forge's own (capabilities, events, event network channels); see ยง4 "Forge 1.20.1". - **MixinExtras** (`io.github.llamalad7:mixinextras-forge`), jar-in-jar in the **Forge jar only** (approved by the user on 2026-10-24): Fabric Loader ships it, Forge 1.20.1 does not, and `LivingEntityMixin` needs it. diff --git a/README.md b/README.md index 2cff2142..ae617dee 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ The other Minecraft versions have their own branches: - **Generator:** burns furnace fuel (9 slots) and powers adjacent turret bases and other machines; an upgrade slot multiplies production and fuel use together - **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 Forge build uses its energy capability (FE) instead +- Optional **NEEPMeat** support (Fabric): vascular conduits power turret bases, 1 eJ per energy unit - Optional **Jade** support for turret bases and turrets, on both loaders ## Requirements diff --git a/build.fabric.gradle.kts b/build.fabric.gradle.kts index 0d2eada5..51e9f32d 100644 --- a/build.fabric.gradle.kts +++ b/build.fabric.gradle.kts @@ -1,3 +1,5 @@ +import java.util.concurrent.Callable + // Fabric nodes (Loom). Shared logic (Java, metadata templating, tests, publishing) is in omlib/build-logic // (mod-common). plugins { @@ -79,6 +81,25 @@ dependencies { // Jade tooltips (optional, not bundled: the mod only registers the plugin when Jade is installed) modCompileOnly("maven.modrinth:jade:${property("jade_version")}") + // NEEPMeat: OMLib's FabricNeepMeatPower lets its vascular network charge the bases. 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/NeepMeatGameTests checks the bases + 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 84b212de..f3b08c85 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -52,6 +52,7 @@ Two directions, so that gameplay code stays loader-free: OMLib creates the implementations of the running loader on first use (`Platform`, `ClientPlatform`), so it does not matter which mod starts first; the `compat` facades (`NetworkCompat`, `MenuCompat`, `ClientNetworkCompat`) forward to them. Energy and items other blocks may use are described loader-free (`core.energy.EnergyAccess`, `inventory.ItemAccess`, exposed by `getEnergyAccess(side)` / `getItemAccess(side)`) and wrapped by thin adapters per loader (Team Reborn Energy and Transfer API on Fabric, FE and item handler capabilities on Forge). +On Fabric with NEEPMeat installed, OMLib also makes them sinks of its vascular network (`FabricNeepMeatPower`, 1 eJ = 1 E). ### How core talks to the game diff --git a/omlib b/omlib index 2eadcf3e..cacdb385 160000 --- a/omlib +++ b/omlib @@ -1 +1 @@ -Subproject commit 2eadcf3e2534906595dde0047ca194973b15714c +Subproject commit cacdb38587e5237ce0ebd5a559f931a75ca8a4cb diff --git a/src/gametest/java/omtteam/openmodularturrets/gametest/platform/fabric/NeepMeatGameTests.java b/src/gametest/java/omtteam/openmodularturrets/gametest/platform/fabric/NeepMeatGameTests.java new file mode 100644 index 00000000..2143a892 --- /dev/null +++ b/src/gametest/java/omtteam/openmodularturrets/gametest/platform/fabric/NeepMeatGameTests.java @@ -0,0 +1,106 @@ +package omtteam.openmodularturrets.gametest.platform.fabric; + +import com.neep.neepmeat.transport.api.pipe.BloodAcceptor; +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.openmodularturrets.blockentity.TurretBaseBlockEntity; +import omtteam.openmodularturrets.gametest.OMTGameTests; +import omtteam.openmodularturrets.registry.ModBlocks; + +/** + * NEEPMeat (Fabric): its vascular network charges turret bases at 1 eJ = 1 E (OMLib's {@code FabricNeepMeatPower}), a + * base taking only what its energy still accepts. + */ +@SuppressWarnings("unused") +public class NeepMeatGameTests implements OMTGameTests { + private static final BlockPos EMITTER = new BlockPos(1, 1, 1); + private static final BlockPos CONDUIT = EMITTER.east(); + private static final BlockPos BASE = CONDUIT.east(); + /** Power of the emitter in the network test, eJ per tick (below the tier three base's 1000 E/t intake). */ + private static final int EMITTER_POWER = 400; + /** Tier one base: its energy accepts 50 E per tick and holds 5000 (config defaults). */ + private static final long TIER_ONE_INTAKE = 50; + + /** + * Power emitter, vascular conduit, tier three base: the conduit finds the base as a sink when placed, and the base + * is charged with the emitter's whole output, in whole ticks of it. + */ + @GameTest(template = EMPTY_STRUCTURE, batch = "neepmeat_network", timeoutTicks = 200) + public void vascularNetworkChargesABase(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(BASE, ModBlocks.TURRET_BASES.get(2)); + EnergyStore energy = ((TurretBaseBlockEntity) helper.getBlockEntity(BASE)).getLogic().getEnergy(); + placeAsPlayer(helper, CONDUIT, block("vascular_conduit")); + helper.succeedWhen(() -> { + long amount = energy.getAmount(); + helper.assertTrue(amount >= EMITTER_POWER * 20L, "The base holds only " + amount + " E"); + helper.assertTrue(amount % EMITTER_POWER == 0, + "The base holds " + amount + " E, not whole ticks of " + EMITTER_POWER + " eJ"); + clear(helper); + }); + } + + /** + * The base as a sink: a plain (not active) sink that claims only its energy's intake per tick, charges that much + * each tick, asks the network for a new share when it is full and then claims nothing. + */ + @GameTest(template = EMPTY_STRUCTURE, batch = "neepmeat_sink", timeoutTicks = 300) + public void baseClaimsOnlyWhatItsEnergyAccepts(GameTestHelper helper) { + helper.setBlock(BASE, ModBlocks.TURRET_BASES.get(0)); + EnergyStore energy = ((TurretBaseBlockEntity) helper.getBlockEntity(BASE)).getLogic().getEnergy(); + BloodAcceptor sink = BloodAcceptor.SIDED.find(helper.getLevel(), helper.absolutePos(BASE), Direction.WEST); + helper.assertTrue(sink != null, "The base is no sink of a vascular network"); + helper.assertTrue(sink.getMode() == BloodAcceptor.Mode.SINK, "The base is a " + sink.getMode() + " sink"); + int[] updates = {0}; + sink.setChangeListener(changed -> updates[0]++); + helper.assertTrue(sink.getDemandHint() == TIER_ONE_INTAKE, "The base asks for " + sink.getDemandHint() + " eJ/t"); + // 1 per unit = 1000 eJ/t on offer: the base takes its 50 + float taken = sink.updateInflux(1f); + helper.assertTrue(Math.round(taken * 1000) == TIER_ONE_INTAKE, "The base took " + taken * 1000 + " eJ/t of 1000"); + long start = helper.getTick(); + helper.succeedWhen(() -> { + helper.assertTrue(energy.getFreeSpace() == 0, "The base is not full yet (" + energy.getAmount() + " E)"); + long ticks = helper.getTick() - start; + long expected = energy.getCapacity() / TIER_ONE_INTAKE; + helper.assertTrue(Math.abs(ticks - expected) <= 2, "Filling took " + ticks + " ticks, not " + expected); + helper.assertTrue(updates[0] > 0, "The full base did not ask the network for a new share"); + helper.assertTrue(sink.getDemandHint() == 0, "The full base still asks for " + sink.getDemandHint() + " eJ/t"); + helper.assertTrue(sink.updateInflux(1f) == 0f, "The full base still takes power"); + sink.setChangeListener(null); + clear(helper); + }); + } + + 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); + } + + private static void clear(GameTestHelper helper) { + helper.setBlock(CONDUIT, Blocks.AIR); + helper.setBlock(EMITTER, Blocks.AIR); + helper.setBlock(BASE, Blocks.AIR); + } +} diff --git a/src/gametest/resources/fabric.mod.json b/src/gametest/resources/fabric.mod.json index f4fb23e6..bf31bba2 100644 --- a/src/gametest/resources/fabric.mod.json +++ b/src/gametest/resources/fabric.mod.json @@ -16,6 +16,7 @@ "omtteam.openmodularturrets.gametest.GeneratorGameTests", "omtteam.openmodularturrets.gametest.BaseGuiGameTests", "omtteam.openmodularturrets.gametest.ItemTransferGameTests", + "omtteam.openmodularturrets.gametest.platform.fabric.NeepMeatGameTests", "omtteam.openmodularturrets.gametest.CamoGameTests", "omtteam.openmodularturrets.gametest.CamoMenuGameTests", "omtteam.openmodularturrets.gametest.BlockMoveGameTests", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ac65d863..f43e40a7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,7 +35,8 @@ "openmodularturrets.mixins.json" ], "suggests": { - "jade": "*" + "jade": "*", + "neepmeat": "*" }, "depends": { "fabricloader": ">=${loader_version}", diff --git a/versions/1.20.1-fabric/gradle.properties b/versions/1.20.1-fabric/gradle.properties index 5595035d..1f8f2b60 100644 --- a/versions/1.20.1-fabric/gradle.properties +++ b/versions/1.20.1-fabric/gradle.properties @@ -3,3 +3,7 @@ minecraft_dependency=1.20.1 fabric_api_version=0.92.12+1.20.1 java_version=17 jade_version=11.13.3+fabric +# NEEPMeat (Modrinth): its vascular network charges the bases (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