📄
pasted-code-1795132493277.txt
txt
33 lines
▶
Create a Minecraft 26.3 Fabric mod called "Mob Automata" that lets me turn any existing mob into a programmable cellular automaton via an in-game GUI, without needing any commands.
1. Creative-Only & Operator-Restricted "Automata Wand":
- Add a non-craftable item called "Automata Wand" (do NOT add any crafting recipe for it; make it obtainable only from the Creative Operator/Tools tab or via `/give`).
- Require Creative mode or Operator permission level 2+ to use the Automata Wand or apply GUI changes on the server, preventing Survival players from accessing or abusing it.
- Right-clicking any mob with the Automata Wand opens an interactive "Mob Automata Configuration" GUI screen bound to that specific mob.
- Right-clicking the air or a block with the Automata Wand opens a global "Automata Manager" GUI screen where I can:
- Create, rename, duplicate, or delete named rule presets.
- Toggle a global Pause/Resume button for all active automaton mobs.
- Click a "Step Once" button while paused to advance all assigned mobs by exactly 1 step at a time for debugging.
2. Mob & Rule Editor GUI Screen:
- Inside the GUI screen for a mob (or when editing a preset), include:
- An Active Toggle button (Enabled / Disabled) that overrides normal mob AI when enabled and restores normal AI when disabled.
- A Preset Selector dropdown/cycler to load an existing rule preset onto this mob or save the mob's current rules as a new preset.
- A Step Speed slider or +/- buttons (from 1 tick up to 100 ticks per step).
- A scrollable list of Condition Rows, plus an "+ Add Condition" button and a "Delete" (X) button on each row.
- Each Condition Row must let me configure four fields visually without typing:
1. "Standing On" Block Picker: Clicking this opens a searchable block/item grid picker (or lets me click it while holding a block in my inventory/cursor) to choose any Minecraft block (e.g., White Wool, Stone, Air, Any Block).
2. "Move Direction" Cycler Button: Cycles through all 6 absolute directions (North, South, East, West, Up, Down) AND 6 relative directions (Forward, Back, Left, Right, Up, Down).
3. "Turn Facing" Cycler Button: Cycles through None, Turn Left 90°, Turn Right 90°, Turn Around 180°, Face North, Face South, Face East, Face West.
4. "Replace With" Block Picker: Clicking this opens the same visual block picker to choose any block to place (including Air to clear blocks, or "No Change" to leave the block untouched), plus a toggle for whether to replace the block the mob just left or the block it arrives at.
- Include a "Default / Fallback Rule" row at the bottom that runs whenever the block the mob is standing on doesn't match any condition above.
3. Deterministic 6-Directional Movement & Block Replacement Engine (Minecraft 26.3 Fabric):
- Use Minecraft 26.3's modern Fabric networking (`CustomPayload` / `PayloadTypeRegistry` with `StreamCodec`) to synchronize GUI edits from client to server, validating on the server that the sender has Creative mode or Operator permissions before applying any changes or modifying blocks.
- Save active mob assignments, rule presets, and global pause state persistently in world save data (`SavedData` / NBT) so machines keep their state across world reloads.
- When an active mob executes a step:
- Suppress normal wandering, gravity, water pushing, and pathfinding AI so it moves cleanly onto the exact center (x + 0.5, y, z + 0.5) of the target block in the chosen direction (including moving straight up or down in 3D space).
- Prevent suffocation damage and block-collision clipping when moving through solid blocks or vertically.
- Replace the designated target block cleanly with the chosen block state.
- Display a subtle floating label or particle indicator above assigned mobs when holding the Automata Wand so I can easily tell which mobs are active and which preset they are running.
Created the wand texture and a standalone rule model for selecting conditions, turning, moving, and choosing a replacement position.
The mod is not yet playable. Item registration, GUIs, server permissions and networking, persistence, mob control, and indicators are still missing. The wand cannot yet be obtained in-game.
Continue building the "Mob Automata" mod by implementing all remaining parts so it is fully playable in-game:
- Item Registration & Permissions:
- Register the "Automata Wand" item using the existing wand texture and add it strictly to the Creative Operator/Tools tab (no crafting recipe).
- Check on both client and server that the player is in Creative mode or has Operator permission level 2+ before opening GUIs or accepting rule updates.
- Networking & World Persistence:
- Register
CustomPayloadpackets (PayloadTypeRegistry+StreamCodec) to sync mob rule configurations, preset updates, global pause toggles, and "Step Once" actions between client and server. - Store all assigned mob UUIDs, active rule configurations, named presets, and global pause state in server
SavedDataso they persist across world reloads.
- Mob Execution Engine & Visual Indicators:
- On the server tick, step each active assigned mob according to its configured step speed (unless globally paused, or when triggered by "Step Once").
- Suppress normal mob AI, gravity, water pushing, collisions, and suffocation damage on active automaton mobs so they snap cleanly to the exact block center (
x + 0.5, y, z + 0.5) in any of the 6 absolute or relative directions (including Up and Down) and replace the designated block (either the block left behind or the block arrived at). - Render subtle particles or floating preset labels above active automaton mobs whenever the player holds the Automata Wand.
- In-Game GUIs:
- Right-clicking a mob with the Automata Wand opens the "Mob Automata Configuration" GUI screen bound to that mob (with Active toggle, Preset loader/saver, Step Speed controls, scrollable Condition Rows with visual Block Pickers, 6-way Move Direction, Turn Facing, Replace With Block Picker + Leave/Arrive toggle, and Default Fallback row).
- Right-clicking air or a block with the Automata Wand opens the global "Automata Manager" GUI screen (to manage presets, toggle global Pause/Resume, and trigger Step Once).
Wire the wand, server permissions, networking, and persistent world state.
Add the automaton tick engine and wand-visible indicators.
Build the manager and mob rule editor with visual block selection.
Registered the Automata Wand with its existing texture in the Operator Items tab. It has no recipe; it can also be obtained with /give.
The mod is not yet playable. The wand does not open screens yet, and permissions, networking, persistence, mob execution, and indicators remain unimplemented.
Focus on singleplayer first (skip custom multiplayer network packets for now and update the integrated server world state directly from the client screens) so the mod becomes playable in this step:
- Permissions & Persistence:
- Require Creative mode or Operator permission level 2+ to use the Automata Wand.
- Store active mob UUID rules, named presets, and global pause state in
SavedDataso they persist across world reloads.
- Mob Tick Engine & Wand Indicators:
- On server tick, step active automaton mobs at their configured tick interval (unless globally paused, or on "Step Once"). Suppress normal AI, gravity, collisions, and suffocation damage so mobs snap to exact block centers (
x + 0.5, y, z + 0.5) across all 6 directions (North, South, East, West, Up, Down + relative directions) and replace the target block (either the block left or the block arrived at). - Show subtle particles or floating labels above active automaton mobs when holding the Automata Wand.
- Wand Right-Click Actions & GUIs:
- Right-clicking a mob with the Automata Wand opens the Mob Automata Configuration screen (Active toggle, Preset selector/saver, Step Speed +/-, scrollable Condition Rows with clickable Block Picker grid, 6-way Move Direction, Turn Facing, Replace With Block Picker + Leave/Arrive toggle, and Default Fallback row).
- Right-clicking air or a block with the Automata Wand opens the Automata Manager screen (preset management, global Pause/Resume button, and Step Once button).
I’ll connect the existing rule model to integrated-server state, then add the tick engine and client screens. Remote multiplayer will remain unsupported.
Added a SavedData model for mob assignments, presets, and the global pause state.
The mod is still not playable. The wand actions, permission checks, tick engine, indicators, and GUIs remain unimplemented, and nothing yet connects the new saved data to gameplay. The wand is creative-only; it has no survival recipe.
package com.kodari.mobautomata;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
public final class MobAutomata implements ModInitializer {
public static final String MOD_ID = "mob_automata";
private static final ResourceKey<Item> WAND_KEY = ResourceKey.create(
Registries.ITEM, Identifier.fromNamespaceAndPath(MOD_ID, "automata_wand"));
public static final Item WAND = Registry.register(BuiltInRegistries.ITEM, WAND_KEY,
new Item(new Item.Properties().setId(WAND_KEY).stacksTo(1)));
private static final ResourceKey<CreativeModeTab> OPERATOR_TAB = ResourceKey.create(
Registries.CREATIVE_MODE_TAB, Identifier.withDefaultNamespace("op_blocks"));
@Override
public void onInitialize() {
CreativeModeTabEvents.modifyOutputEvent(OPERATOR_TAB).register(output -> {
if (output.shouldShowOpRestrictedItems()) {
output.accept(new ItemStack(WAND));
}
});
}
}