Skip to content

Commit f7ac768

Browse files
committed
feat: add idea chip functionality for gated research in Research Station to the todo.lock
1 parent 73c7343 commit f7ac768

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

todo.lock

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,107 @@ PHASE 10 — UI & Visual Improvements
403403
Processing) + 9 entries with multi-page content covering research station workflow,
404404
tiers, all 4 fluids with crafting references, drives, drive crafting table,
405405
and processing station. Book auto-registered by Patchouli as researchcube:guide.
406+
407+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
408+
[TODO — PHASE 21 — Research Idea Chips (Pack-Dev Research Gates)]
409+
(Allows pack developers to gate specific research behind a custom broken drive "idea chip"
410+
item with a unique name and/or NBT. The chip is placed in a new dedicated slot in the
411+
Research Station and is consumed when research begins. Distribution to players is handled
412+
entirely by the pack dev via quests, loot tables, or other means.)
413+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
414+
415+
- [ ] [AI] ResearchDefinition: add optional `idea_chip` field
416+
ResearchDefinition gains an Optional<ItemStack> ideaChip field (default Optional.empty()).
417+
The field is parsed from an optional "idea_chip" JSON object in the research definition file:
418+
{
419+
"idea_chip": {
420+
"item": "researchcube:metadata_broken",
421+
"components": {
422+
"minecraft:custom_name": "{\"text\":\"Idea: Advanced Alloys\",\"italic\":false}",
423+
"minecraft:custom_data": { "researchcube_chip_id": "advanced_alloys" }
424+
}
425+
}
426+
}
427+
Codec: use ItemStack.CODEC (or a manual MapCodec) wrapped in Codec.optionalField().
428+
ResearchManager must pass through the new field when constructing ResearchDefinition.
429+
430+
- [ ] [AI] ItemStack partial-match helper utility
431+
Add a static helper IdeaChipMatcher.matches(ItemStack required, ItemStack candidate):
432+
- Item registry name must be equal.
433+
- For each DataComponentType declared in required.getComponents(), the candidate must
434+
have the same value for that component. Components present only in the candidate
435+
but not in required are ignored (partial match).
436+
This lets pack devs declare only the components they care about (e.g. just a custom name)
437+
without having to enumerate every default component on the item.
438+
Place in com.researchcube.util.IdeaChipMatcher.
439+
440+
- [ ] [AI] ResearchTableBlockEntity: idea chip inventory slot
441+
Add one new inventory slot (index 9, shifting previous slot count from 9 to 10).
442+
Slot is unrestricted by item type (any item may be placed there by the player).
443+
In tryStartResearch(): after all existing validation, if the selected research definition
444+
has a non-empty ideaChip:
445+
- Retrieve the item in slot 9.
446+
- Call IdeaChipMatcher.matches(required, candidate). If false → send failure feedback
447+
to the player ("Missing idea chip: <chip display name>") and return without starting.
448+
- If true → shrink slot 9 stack by 1 (consume the chip) and proceed normally.
449+
In cancelResearchWithRefund(): the idea chip is NOT refunded (it was the entry price;
450+
research was at least started). Add a note comment to this effect.
451+
NBT persistence: slot 9 is saved/loaded with the rest of the inventory automatically
452+
(ContainerHelper.saveAllItems / loadAllItems already iterates all slots by index, so no
453+
extra NBT changes needed as long as the slot count constant is updated).
454+
455+
- [ ] [AI] ResearchTableMenu: register the new slot
456+
Increment slot count constant from 9 to 10. Add the idea chip slot to the container
457+
with a SlotItemHandler at slot index 9. Position: TBD during screen layout step below.
458+
Ensure the slot is included in the shift-click quick-move logic.
459+
460+
- [ ] [AI] ResearchTableScreen: render the idea chip slot + contextual feedback
461+
Add a dedicated visual slot to the Research Station GUI for the idea chip (index 9).
462+
Suggested position: below the drive slot or next to the Start button, clearly separated
463+
from the cost item slots. Render a subtle "chip" icon or label ("Idea") above the slot.
464+
465+
Contextual behavior:
466+
- When the currently selected research has no idea_chip requirement: render the slot
467+
with a dimmed/greyed overlay and a tooltip "No idea chip required for this research."
468+
- When the requirement exists and the slot is empty or mismatched: render a red-tinted
469+
border or highlight on the slot and disable (grey out) the Start button with an
470+
additional tooltip line "Requires idea chip: <chip display name>".
471+
- When the requirement is satisfied: slot renders normally, Start button is enabled.
472+
473+
The slot state is determined client-side by comparing the idea chip requirement (synced
474+
from the server) against the current slot contents (synced automatically by the container).
475+
476+
- [ ] [AI] Network sync: send ideaChip to client
477+
ResearchTableScreen needs to show the tooltip name of the required chip client-side.
478+
Options (pick simplest):
479+
a) Include ideaChip ItemStack in the existing openMenu FriendlyByteBuf payload
480+
(alongside the completed-research set already sent there). Rebuild when the player
481+
selects a different research entry via a new small S→C packet or by re-opening the
482+
menu. Preferred if the menu is already rebuilt on research selection.
483+
b) Add a new SyncSelectedResearchPacket (server→client) that carries the full
484+
ResearchDefinition (or just id + ideaChip) for the currently selected research,
485+
sent whenever the selection changes. Store it in ResearchTableScreen.
486+
Either way the client must be able to read the required chip's display name and
487+
components to compare against the slot contents and render the tooltip correctly.
488+
489+
- [ ] [AI] Broken drive item: ensure it can carry arbitrary components (no-op if already works)
490+
Verify that metadata_broken (BrokenDriveItem or however the broken drive is registered)
491+
does not strip or override custom_name / custom_data components. If it does, ensure these
492+
pass through cleanly so pack devs can attach names and data via item_modifiers or
493+
give commands without the item resetting them.
494+
495+
- [ ] [AI] Update example research JSONs + DATAPACK.md
496+
Add idea_chip to one example research definition (e.g. a new "gated_example" or an
497+
amendment to an existing one) to validate end-to-end functionality.
498+
Add an "Idea Chips" section to DATAPACK.md explaining:
499+
- JSON schema for the idea_chip field.
500+
- How to create a custom chip via /give, item_modifier loot function, or datapack items.
501+
- Partial-match semantics (only declared components are checked).
502+
- That the chip is consumed on research start and is NOT refunded on cancel.
503+
- Recommended practice: use a unique minecraft:custom_data tag as a stable ID, and
504+
set a human-readable minecraft:custom_name for player-facing display.
505+
506+
- [ ] [AI] Update example_datapack/ with a gated research example
507+
Add a research definition that uses idea_chip and a matching drive crafting recipe.
508+
Include a sample loot_table or item_modifier JSON showing how a pack dev would
509+
distribute the chip (e.g. as a reward item in a loot table).

0 commit comments

Comments
 (0)