Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fdec3f1
Add shared machine upgrades and processor working-area displays
faceofcat Nov 17, 2026
c8085a9
Merge branch 'codex/mod-creative-tabs' into codex/machine-upgrades-di…
faceofcat Nov 17, 2026
3db4f2f
Update machine fixtures for inherited component upgrades
faceofcat Nov 17, 2026
4678f6d
Support configurable machine facing and placement preferences
faceofcat Nov 17, 2026
332143b
Add fluid tags and mod-owned machine admission rules
faceofcat Nov 17, 2026
ed3f5ae
Expose transactional typed resources to machine processors
faceofcat Nov 17, 2026
5d073c6
Add processor placement preferences and accepted-placement callbacks
faceofcat Nov 17, 2026
20c724c
Expose existing machine redstone sources to comparators
faceofcat Nov 17, 2026
fa05158
Compose independent processors over shared machine resources
faceofcat Nov 17, 2026
a82ec44
Deliver Java callbacks for every recipe cycle transition
faceofcat Nov 17, 2026
6089113
Delegate machine energy ownership to a selected processor
faceofcat Nov 17, 2026
56d340f
Charge transactional operating energy per successful processor step
faceofcat Nov 17, 2026
63a3782
Preserve aliased energy and authored controls in processor composition
faceofcat Nov 17, 2026
49572c9
Explain the purpose and manual checks for every companion machine
faceofcat Nov 17, 2026
16039b9
Validate recipe diagnostics across shared machine consumers
faceofcat Nov 17, 2026
1c8457f
Update display and working-area tests for vertical facing
faceofcat Nov 17, 2026
d0d01d7
Merge remote-tracking branch 'origin/codex/mod-creative-tabs' into co…
faceofcat Nov 17, 2026
52ac85f
Keep idle processor clocks from dirtying machine saves
faceofcat Nov 17, 2026
a0d8f7c
Make larger upgrade slot stacks an explicit opt-in
faceofcat Nov 17, 2026
fee8ec7
Match working area outlines to six-way machine facing
faceofcat Nov 17, 2026
5680ebc
Merge branch 'codex/machine-upgrades-displays' into codex/machine-por…
faceofcat Nov 17, 2026
bfd5564
Validate comparator source IDs while loading machine definitions
faceofcat Nov 17, 2026
2943c27
Honor the primary processor in keyless lookups and controls
faceofcat Nov 17, 2026
8ea8eef
Avoid neighbour updates during load-time facing repair
faceofcat Nov 17, 2026
d6b2b40
Reuse processor configurations in client sound ticks
faceofcat Nov 17, 2026
270f8fa
Share recipe input admission across Java resources and XML lanes
faceofcat Nov 17, 2026
6416610
Merge pull request #113 from MinecraftModDevelopmentMods/codex/machin…
dshadowwolf Nov 17, 2026
8136911
Bring merged machine upgrade and porting stack onto main
faceofcat Nov 18, 2026
0d3dd84
Fix invalid UTF-8 in machine upgrade documentation
faceofcat Nov 18, 2026
bd3587d
Document multiple processors in the storage overview
faceofcat Nov 18, 2026
6a4314f
Clear fractional processor work when a cycle becomes idle
faceofcat Nov 18, 2026
a173057
Hide item capabilities for manual-only machine storage
faceofcat Nov 18, 2026
57b1fba
Scope example fluid admission lookup to its recipe type
faceofcat Nov 18, 2026
245413f
Validate range upgrade sprite height
faceofcat Nov 18, 2026
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
# Local Maven repository (publishAllPublicationsToLocalRepository)
/mcmodsrepo/
/.eclipse/

# Python asset-generator caches
__pycache__/
*.py[cod]
212 changes: 202 additions & 10 deletions docs/gui-screens.md

Large diffs are not rendered by default.

410 changes: 405 additions & 5 deletions docs/xml-machines.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion scripts/companion.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ sourceSets {
}
}

// Unit definition tests load the real companion XML and its mod-owned processors.
sourceSets.test.runtimeClasspath += sourceSets.companion.output

neoForge.addModdingDependenciesTo(sourceSets.companion)
neoForge.addModdingDependenciesTo(sourceSets.companionTest)
neoForge.addModdingDependenciesTo(sourceSets.companionServerTest)
Expand Down Expand Up @@ -94,7 +97,7 @@ neoForge {
gameDirectory = layout.buildDirectory.dir('companion-gametest')
sourceSet = sourceSets.companionServerTest
loadedMods = [neoForge.mods.named(mod_id).get(), neoForge.mods.mmdlib_companion_test]
systemProperty 'neoforge.enabledGameTestNamespaces', 'mmdlib_companion'
systemProperty 'neoforge.enabledGameTestNamespaces', project.hasProperty('portingHooksOnly') ? 'mmdlib_porting' : 'mmdlib_companion,mmdlib_porting'
}
multiblockClientSmoke {
client()
Expand Down
72 changes: 72 additions & 0 deletions scripts/generate_gui_sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,77 @@ def arrow(img, x, y, down, colour):
write_png("icon_side_config", outlined(img))


def write_upgrade_sprites():
"""Hand-pixelled 16px circuit-module tab and permanent component socket glyphs."""
palette = {
'.': CLEAR, 'o': (29, 39, 46, 255),
's': (67, 83, 92, 255), 'm': (116, 139, 148, 255),
'h': (191, 212, 215, 255), 'w': (232, 243, 233, 255),
't': (27, 95, 89, 255), 'c': (53, 155, 135, 255),
'b': (100, 219, 177, 255), 'g': (207, 151, 66, 255),
'y': (251, 216, 118, 255),
}
sprites = {
'icon_upgrades': [
'................',
'...g.g.g.g.g....',
'..ooooooooooo...',
'.gohtttttttto...',
'..otbbctctcto.g.',
'.gotctcttttto...',
'..ottttooyyooog.',
'.gotctoyyyyyyo..',
'..otttyyoooooyo.',
'.gottyyohhsooyo.',
'..ottyyohssooyo.',
'.gotctoyooooyo..',
'..oooooyyyyyyo..',
'...g.g.ooyyoo...',
'................',
'................',
],
'socket_gearbox': [
'................',
'....ss..........',
'..sshhss........',
'..shmmhs........',
'.shmssmhs.......',
'.shs..sms.......',
'..smssms..ss....',
'..ssmmss.swws...',
'....ss..shmmhs..',
'.......shmssmhs.',
'.......sms..sms.',
'........smssms..',
'........ssmmss..',
'..........ss....',
'................',
'................',
],
'socket_capacitor': [
'................',
'.....hh..hh.....',
'.....ms..ms.....',
'....ssssssss....',
'...shhhhhhhms...',
'...shmccccmss...',
'...shcbcbcmss...',
'...shcbbccmss...',
'...shccbcbmss...',
'...shmccccmss...',
'...shmmmmmmss...',
'...smmmmmmsss...',
'....ssssssss....',
'................',
'................',
'................',
],
}
for name, rows in sprites.items():
assert len(rows) == 16 and all(len(row) == 16 for row in rows), name
write_png(name, [[palette[pixel] for pixel in row] for row in rows])


def main():
OUT.mkdir(parents=True, exist_ok=True)
print(f"writing to {OUT}:")
Expand All @@ -462,6 +533,7 @@ def main():
write_filter_icons()
write_flat_buttons()
write_side_config_sprites()
write_upgrade_sprites()
write_png("checkbox", checkbox(False))
write_png("checkbox_selected", checkbox(True))
write_png("radio", radio(False))
Expand Down
90 changes: 90 additions & 0 deletions scripts/generate_upgrade_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""Pixel-art upgrade modules, using the same PNG writer as our GUI sprites."""
from pathlib import Path
import generate_gui_sprites as sprites


def generate():
# Steel frame, teal circuit board, gold contacts and a four-way range symbol.
palette = {
'.': (0, 0, 0, 0),
'o': (32, 40, 46, 255),
's': (84, 103, 113, 255),
'h': (181, 205, 209, 255),
'b': (24, 72, 70, 255),
't': (37, 119, 102, 255),
'g': (218, 166, 61, 255),
'y': (255, 221, 112, 255),
'a': (131, 241, 174, 255),
'w': (218, 255, 224, 255),
}
sprites.OUT = Path(__file__).resolve().parents[1] / 'src/main/resources/assets/mmdlib/textures/item'
sprites.OUT.mkdir(parents=True, exist_ok=True)
# Matching steel module with two meshing brass gears and a dark axle hub.
rows = [
'................',
'..oooooooooooo..',
'.ohhhhhhhhhhhso.',
'.ohbbbbbbbbbbso.',
'.ohbbggbbbbbbso.',
'.ohbggyygbbbbso.',
'.ohgygooggbbbso.',
'.ohgygooggygbso.',
'.ohbggyygoogbso.',
'.ohbbggggoogbso.',
'.ohbbbbgyyggbso.',
'.ohbbbbbggbbbso.',
'.osssssssssssso.',
'..ooggyggyggoo..',
'....ygyygygy....',
'................',
]
assert len(rows) == 16 and all(len(row) == 16 for row in rows)
sprites.write_png('gearbox_upgrade', [[palette[pixel] for pixel in row] for row in rows])
# Paired cylindrical capacitors with bright contacts, in the shared module frame.
palette['c'] = (58, 148, 207, 255)
palette['l'] = (137, 225, 255, 255)
rows = [
'................',
'..oooooooooooo..',
'.ohhhhhhhhhhhso.',
'.ohbbbbbbbbbbso.',
'.ohbggbbggbbbso.',
'.ohcllccllcbbso.',
'.ohcltccltcbbso.',
'.ohcltccltcbbso.',
'.ohclwcclwcbbso.',
'.ohcltccltcbbso.',
'.ohcssccsscbbso.',
'.ohbggbbggbbbso.',
'.osssssssssssso.',
'..ooggyggyggoo..',
'....ygyygygy....',
'................',
]
assert len(rows) == 16 and all(len(row) == 16 for row in rows)
sprites.write_png('capacitor_upgrade', [[palette[pixel] for pixel in row] for row in rows])

# Shared range module: four-way expansion arrows.
rows = [
'................',
'..oooooooooooo..',
'.ohhhhhhhhhhhso.',
'.ohbbbbbbbbbbso.',
'.ohbttbaabttbso.',
'.ohbtbaaaabtbso.',
'.ohbttbaabttbso.',
'.ohbaabwabaabso.',
'.ohaaaawwaaaaso.',
'.ohbaabwabaabso.',
'.ohbttbaabttbso.',
'.ohbtbaaaabtbso.',
'.osssssssssssso.',
'..ooggyggyggoo..',
'....ygyygygy....',
'................',
]
assert len(rows) == 16 and all(len(row) == 16 for row in rows)
sprites.write_png('range_upgrade', [[palette[pixel] for pixel in row] for row in rows])

if __name__ == '__main__':
generate()
64 changes: 64 additions & 0 deletions src/companion/java/zone/moddev/mc/companion/AdmissionDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package zone.moddev.mc.companion;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.SingleRecipeInput;

import zone.moddev.mc.lib.machine.feature.ProcessorMachine;
import zone.moddev.mc.lib.machine.feature.ProcessorState;
import zone.moddev.mc.lib.machine.feature.StorageAdmission;
import zone.moddev.mc.lib.machine.feature.StoredProcessor;
import zone.moddev.mc.lib.machine.ingredient.FluidAmount;
import zone.moddev.mc.lib.machine.ingredient.MachineIngredient;
import zone.moddev.mc.lib.machine.neoforge.MachineContent;

/** A custom processor can also supply live insertion rules without casts. */
public final class AdmissionDemo extends StoredProcessor
implements StorageAdmission {
private static final ResourceLocation STILL_RECIPE_TYPE = ResourceLocation
.parse("mmdlib_companion:lava_smelting");

/** A consuming mod can supply this value from its own reloadable config. */
public static volatile ResourceLocation fuelTag = ResourceLocation
.parse("minecraft:lava");

@Override
public boolean acceptsItem(ProcessorMachine host, String member,
ItemStack stack) {
if (member.startsWith("fuel/"))
return stack.getBurnTime(RecipeType.SMELTING) > 0;
return host.level() != null
&& host.level().getRecipeManager().getRecipeFor(RecipeType.SMELTING,
new SingleRecipeInput(stack), host.level()).isPresent();
}

@Override
public boolean acceptsFluid(ProcessorMachine host, String member,
FluidAmount fluid) {
if (member.equals("oil"))
return fluid.fluid().is(TagKey.create(Registries.FLUID, fuelTag));
if (host.level() == null)
return false;
// Query the current manager by type: bounded work and reload-safe.
return MachineContent.recipeType(STILL_RECIPE_TYPE)
.recipes(host.level().getRecipeManager()).stream()
.anyMatch(holder -> holder.value().recipe().inputs()
.getOrDefault("fuel", java.util.List.of()).stream().anyMatch(
part -> part instanceof MachineIngredient.FluidPart input
&& input.fluids().contains(fluid.fluid())));
}

@Override
public boolean canStart(ProcessorState state, ProcessorMachine context) {
return false;
}

@Override
public ProcessState process(ProcessorState state, ProcessorMachine context,
int ticks) {
return ProcessState.IDLE;
}
}
43 changes: 43 additions & 0 deletions src/companion/java/zone/moddev/mc/companion/BatteryBank.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package zone.moddev.mc.companion;

import net.minecraft.core.Direction;

import zone.moddev.mc.lib.api.capabilities.EnergyBuffer;
import zone.moddev.mc.lib.api.capabilities.IoMode;
import zone.moddev.mc.lib.machine.feature.ProcessorEnergy;
import zone.moddev.mc.lib.machine.feature.ProcessorMachine;
import zone.moddev.mc.lib.machine.feature.ProcessorState;
import zone.moddev.mc.lib.machine.feature.StoredProcessor;

/**
* Processor-owned energy, with side policy applied to cached capability views.
*/
public final class BatteryBank extends StoredProcessor
implements ProcessorEnergy {
private EnergyBuffer buffer;
public EnergyBuffer createEnergyStorage(long capacity, long input,
long output) {
if (buffer != null)
throw new IllegalStateException("Already bound");
return buffer = new EnergyBuffer(capacity, input, output);
}
public EnergyBuffer buffer() {
return buffer;
}
public IoMode energyMode(Direction side) {
if (paused())
return IoMode.DISABLED;
return side == null
? IoMode.BOTH
: side == Direction.UP
? IoMode.INPUT
: side == Direction.DOWN ? IoMode.OUTPUT : IoMode.DISABLED;
}
public boolean canStart(ProcessorState state, ProcessorMachine machine) {
return false;
}
public ProcessState process(ProcessorState state, ProcessorMachine machine,
int ticks) {
return ProcessState.IDLE;
}
}
45 changes: 45 additions & 0 deletions src/companion/java/zone/moddev/mc/companion/ChargePump.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package zone.moddev.mc.companion;

import zone.moddev.mc.lib.machine.feature.ProcessorMachine;
import zone.moddev.mc.lib.machine.feature.ProcessorState;
import zone.moddev.mc.lib.machine.feature.StoredProcessor;

/** Example charging alongside recipe lanes: one mB water supplies 100 FE. */
public final class ChargePump extends StoredProcessor {
private final ProcessorState.Key<Integer> starts = variables.define(
"starts", com.mojang.serialization.Codec.INT, 0,
java.util.function.UnaryOperator.identity(), false, true);
private final ProcessorState.Key<Integer> finishes = variables.define(
"finishes", com.mojang.serialization.Codec.INT, 0,
java.util.function.UnaryOperator.identity(), false, true);
private final ProcessorState.Key<String> lastLane = variables.define(
"last_lane", com.mojang.serialization.Codec.STRING, "",
java.util.function.UnaryOperator.identity(), false, true);

public void recordCycle(String lane, boolean finished) {
variables.update(() -> {
var counter = finished ? finishes : starts;
variables.set(counter, variables.get(counter) + 1);
variables.set(lastLane, lane);
});
}

@Override
public boolean canStart(ProcessorState state, ProcessorMachine host) {
return host.resources().fluids("coolant").free(0) > 0;
}

@Override
public ProcessState process(ProcessorState state, ProcessorMachine host,
int ticks) {
var resources = host.resources();
try (var tx = resources.begin()) {
if (resources.energy("energy").insert(100, tx) != 100)
return ProcessState.BLOCKED;
if (resources.fluids("coolant").extract(0, 1, tx) != 1)
return ProcessState.IDLE;
tx.commit();
}
return ProcessState.RUNNING;
}
}
16 changes: 16 additions & 0 deletions src/companion/java/zone/moddev/mc/companion/CompanionMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public final class CompanionMod {
}

public CompanionMod(IEventBus bus) {
MaterialExtensions.GLOBAL.events().registerCallback(
id("workshop_start"), MaterialEventTypes.MACHINE_CYCLE_START,
event -> recordWorkshopCycle(event, false));
MaterialExtensions.GLOBAL.events().registerCallback(
id("workshop_finish"), MaterialEventTypes.MACHINE_CYCLE_FINISH,
event -> recordWorkshopCycle(event, true));
MultiblockDemo.register(bus);
CompanionWidgets.register();
CompanionAddons.register(bus);
Expand All @@ -100,6 +106,16 @@ public CompanionMod(IEventBus bus) {
});
}

private static void recordWorkshopCycle(
zone.moddev.mc.lib.api.MaterialEventContexts.MachineCycle event,
boolean finished) {
if (event
.machine() instanceof zone.moddev.mc.lib.machine.neoforge.DefinedMachineEntity machine)
machine.features.findProcessor("charge", ChargePump.class)
.ifPresent(
pump -> pump.recordCycle(event.processor(), finished));
}

private static void capabilities(RegisterCapabilitiesEvent event) {
CompanionAddons.capabilities(event);
for (var machine : MACHINES) {
Expand Down
Loading
Loading