Skip to content

Add game tests for all advancement criteria; fix advancement JSON files for PartReaderAspectTrigger/PartWriterAspectTrigger codec key#1617

Merged
rubensworks merged 4 commits intomaster-1.21-ltsfrom
copilot/implement-game-tests-for-advancements
Feb 28, 2026
Merged

Add game tests for all advancement criteria; fix advancement JSON files for PartReaderAspectTrigger/PartWriterAspectTrigger codec key#1617
rubensworks merged 4 commits intomaster-1.21-ltsfrom
copilot/implement-game-tests-for-advancements

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Adds game tests covering all 40 advancements in IntegratedDynamics, and fixes the advancement JSON files where the part_type key did not match the codec field name parttype used by PartReaderAspectTrigger and PartWriterAspectTrigger, silently disabling the part-type condition.

Bug fixes

  • Advancement JSON files for part_reader_aspect / part_writer_aspect triggers: The JSON files used "part_type" but the codec field name is "parttype". This caused the part-type condition to always be empty (ignored) when loading advancements from JSON — any aspect reader/writer event would match regardless of part type. Fixed in: redstone_capturing.json, recipe_reading.json, redstone_transmission.json, smart_pressure_plate.json, sponge_step_sound.json.

  • LabelsWorldStorage.onPlayerLoggedIn: Wrapped sendToPlayer in a try-catch so mock players (no real connection, e.g. in game tests) don't cause event bus exceptions.

New game tests

GameTestsAdvancements — 29 test methods covering all 40 advancement criteria across every trigger type. Where possible, tests simulate actual game logic rather than invoking criterion triggers directly (e.g. player.addItem() to fire INVENTORY_CHANGED, PlayerEvent.ItemCraftedEvent to fire crafting triggers, PlayerContainerEvent.Open to fire the GUI open trigger):

Trigger Advancements covered
cyclopscore:item_crafted / inventory_changed root, meneglin basics, network foundations, basic network components
integrateddynamics:variable_created constant definition, variable materialization/proxying, recipe creation
integrateddynamics:network_initialized networks_logic (≥10 cables)
integrateddynamics:part_reader_aspect redstone capturing, recipe reading
integrateddynamics:part_variable_driven redstone observement, arithmetic addition, lectern data/book/book name, recipe lookup, logical list building, what would I be looking at, dynamic additions/filtering, creeper taming, recursive recursion, tool for obsidian
integrateddynamics:part_writer_aspect redstone transmission, smart pressure plate, sponge step sound

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copilot AI changed the title [WIP] Add game tests for all advancements in mod Add game tests for all advancement criteria; fix PartReaderAspectTrigger/PartWriterAspectTrigger codec key mismatch Feb 28, 2026
@coveralls
Copy link

coveralls commented Feb 28, 2026

Coverage Status

coverage: 45.559% (+1.1%) from 44.477%
when pulling dfa01e7 on copilot/implement-game-tests-for-advancements
into 1d05607 on master-1.21-lts.

Copy link
Member

@rubensworks rubensworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And after implementing these changes, make sure all game tests pass.

p_311401_ -> p_311401_.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(PartReaderAspectTrigger.Instance::player),
Codecs.PART_TYPE.optionalFieldOf("parttype").forGetter(PartReaderAspectTrigger.Instance::partType),
Codecs.PART_TYPE.optionalFieldOf("part_type").forGetter(PartReaderAspectTrigger.Instance::partType),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you can keep this here as-is. Instead, just fix the JSON advancement files to use "parttype" instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dfa01e7. Reverted the codec key back to "parttype" and updated redstone_capturing.json and recipe_reading.json to use "parttype" instead.

p_311401_ -> p_311401_.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(PartWriterAspectTrigger.Instance::player),
Codecs.PART_TYPE.optionalFieldOf("parttype").forGetter(PartWriterAspectTrigger.Instance::partType),
Codecs.PART_TYPE.optionalFieldOf("part_type").forGetter(PartWriterAspectTrigger.Instance::partType),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you can keep this here as-is. Instead, just fix the JSON advancement files to use "parttype" instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dfa01e7. Reverted the codec key back to "parttype" and updated redstone_transmission.json, smart_pressure_plate.json, and sponge_step_sound.json to use "parttype" instead.

public void testAdvancementMenrilProduction(GameTestHelper helper) {
ServerPlayer player = helper.makeMockServerPlayerInLevel();
ItemStack crystalBlock = new ItemStack(RegistryEntries.BLOCK_CRYSTALIZED_MENRIL_BLOCK.get());
CriteriaTriggers.INVENTORY_CHANGED.trigger(player, player.getInventory(), crystalBlock);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where possible, can you make sure to simulate the actual game logic instead of invoking the criterion triggers directly?
Here, for example, instead of calling the trigger, you can add the item to the inventory of the player to invoke the trigger implicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dfa01e7. Updated all tests to use game logic where possible:

  • testAdvancementRoot: fires PlayerEvent.ItemCraftedEvent (which triggers ModItemObtainedTrigger via its event listener)
  • testAdvancementMeneglinDiscovery / testAdvancementMenrilProduction: calls player.addItem() which fires INVENTORY_CHANGED via the player's container slot listener
  • fireItemCraftedTrigger: fires PlayerEvent.ItemCraftedEvent (which triggers ItemCraftedTrigger via its event listener)
  • testAdvancementLogicProgramming: fires PlayerContainerEvent.Open (which triggers GuiContainerOpenTrigger via its event listener)

…ancement tests

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 28, 2026

And after implementing these changes, make sure all game tests pass.

All 850 game tests pass after these changes.

Copilot AI changed the title Add game tests for all advancement criteria; fix PartReaderAspectTrigger/PartWriterAspectTrigger codec key mismatch Add game tests for all advancement criteria; fix advancement JSON files for PartReaderAspectTrigger/PartWriterAspectTrigger codec key Feb 28, 2026
@rubensworks rubensworks marked this pull request as ready for review February 28, 2026 14:36
@rubensworks rubensworks merged commit b464674 into master-1.21-lts Feb 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants