Add game tests for all advancement criteria; fix advancement JSON files for PartReaderAspectTrigger/PartWriterAspectTrigger codec key#1617
Conversation
Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
rubensworks
left a comment
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
Actually, you can keep this here as-is. Instead, just fix the JSON advancement files to use "parttype" instead.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
Actually, you can keep this here as-is. Instead, just fix the JSON advancement files to use "parttype" instead.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done in dfa01e7. Updated all tests to use game logic where possible:
testAdvancementRoot: firesPlayerEvent.ItemCraftedEvent(which triggersModItemObtainedTriggervia its event listener)testAdvancementMeneglinDiscovery/testAdvancementMenrilProduction: callsplayer.addItem()which firesINVENTORY_CHANGEDvia the player's container slot listenerfireItemCraftedTrigger: firesPlayerEvent.ItemCraftedEvent(which triggersItemCraftedTriggervia its event listener)testAdvancementLogicProgramming: firesPlayerContainerEvent.Open(which triggersGuiContainerOpenTriggervia its event listener)
…ancement tests Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
All 850 game tests pass after these changes. |
Adds game tests covering all 40 advancements in IntegratedDynamics, and fixes the advancement JSON files where the
part_typekey did not match the codec field nameparttypeused byPartReaderAspectTriggerandPartWriterAspectTrigger, silently disabling the part-type condition.Bug fixes
Advancement JSON files for
part_reader_aspect/part_writer_aspecttriggers: 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: WrappedsendToPlayerin 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 fireINVENTORY_CHANGED,PlayerEvent.ItemCraftedEventto fire crafting triggers,PlayerContainerEvent.Opento fire the GUI open trigger):cyclopscore:item_crafted/inventory_changedintegrateddynamics:variable_createdintegrateddynamics:network_initializedintegrateddynamics:part_reader_aspectintegrateddynamics:part_variable_drivenintegrateddynamics:part_writer_aspect✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.