From ef04e949250073df3eeb1c5511a7d4696ae2617f Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Fri, 6 Dec 2024 01:13:53 +0000 Subject: [PATCH 1/8] Update 1.18 RELEASE_HASH --- .release-info/1.18/RELEASE_HASH | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/RELEASE_HASH b/.release-info/1.18/RELEASE_HASH index 6ed6f8d..097071e 100644 --- a/.release-info/1.18/RELEASE_HASH +++ b/.release-info/1.18/RELEASE_HASH @@ -1 +1 @@ -f90114caa2b504cf129370ac131d1ebbc574c405 +c9d9c25a769d18442685b9f67624e811f348e536 From cc76c388201cb3c2df36a9ba737ce059f3a193fd Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Fri, 6 Dec 2024 01:13:53 +0000 Subject: [PATCH 2/8] Reset 1.18 changelog --- CHANGELOG/1.18/0.2.1.md | 4 ++++ CHANGELOG/1.18/current.md | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG/1.18/0.2.1.md diff --git a/CHANGELOG/1.18/0.2.1.md b/CHANGELOG/1.18/0.2.1.md new file mode 100644 index 0000000..982fd5b --- /dev/null +++ b/CHANGELOG/1.18/0.2.1.md @@ -0,0 +1,4 @@ +# 0.2.1 + +- `[DEV]` Code cleanup +- `[DEV]` Documentation diff --git a/CHANGELOG/1.18/current.md b/CHANGELOG/1.18/current.md index 5cc9571..e69de29 100644 --- a/CHANGELOG/1.18/current.md +++ b/CHANGELOG/1.18/current.md @@ -1,2 +0,0 @@ -- `[DEV]` Code cleanup -- `[DEV]` Documentation From 6d73c5db091568a4d1f689f9f4d0048715812151 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Thu, 5 Dec 2024 21:19:54 -0800 Subject: [PATCH 3/8] Remove the book and references to Cat Herder --- .../grant_book_on_first_join.json | 12 ----- .../loot_tables/grant_book_on_first_join.json | 20 -------- .../patchouli_books/tracking_crafts/book.json | 10 ---- .../en_us/categories/mgmt.json | 5 -- .../en_us/categories/recipes.json | 5 -- .../en_us/entries/mgmt/info.json | 39 ---------------- .../en_us/entries/mgmt/modes.json | 46 ------------------- .../en_us/entries/recipes/mods.json | 30 ------------ .../immersiveengineering/cloche/catnip.json | 29 ------------ .../crusher/wild_catnip.json | 27 ----------- .../squeezer/catnip_seeds.json | 17 ------- 11 files changed, 240 deletions(-) delete mode 100644 src/main/resources/data/crafttracker/advancements/grant_book_on_first_join.json delete mode 100644 src/main/resources/data/crafttracker/loot_tables/grant_book_on_first_join.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/book.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/mgmt.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/recipes.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/info.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/modes.json delete mode 100644 src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/recipes/mods.json delete mode 100644 src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/cloche/catnip.json delete mode 100644 src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/crusher/wild_catnip.json delete mode 100644 src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/squeezer/catnip_seeds.json diff --git a/src/main/resources/data/crafttracker/advancements/grant_book_on_first_join.json b/src/main/resources/data/crafttracker/advancements/grant_book_on_first_join.json deleted file mode 100644 index 95a0771..0000000 --- a/src/main/resources/data/crafttracker/advancements/grant_book_on_first_join.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "criteria": { - "tick": { - "trigger": "minecraft:tick" - } - }, - "rewards": { - "loot": [ - "crafttracker:grant_book_on_first_join" - ] - } -} diff --git a/src/main/resources/data/crafttracker/loot_tables/grant_book_on_first_join.json b/src/main/resources/data/crafttracker/loot_tables/grant_book_on_first_join.json deleted file mode 100644 index 49ca4c2..0000000 --- a/src/main/resources/data/crafttracker/loot_tables/grant_book_on_first_join.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "advancement_reward", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "item", - "name": "patchouli:guide_book", - "functions": [ - { - "function": "set_nbt", - "tag": "{\"patchouli:book\": \"crafttracker:tracking_crafts\"}" - } - ] - } - ] - } - ] -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/book.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/book.json deleted file mode 100644 index 77f52dc..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/book.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "Caring For Your Cat", - "landing_text": "This volume should help you in caring for your cat.$(br2)It will cover recipes that are added by this mod, talents that you can assign to your cats, items that you can make and the recipes associated, and new food items that are available.", - "version": 2, - "show_progress": false, - "creative_tab": "catherder", - "text_overflow_mode": "resize", - "pause_game": true, - "model": "patchouli:book_purple" -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/mgmt.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/mgmt.json deleted file mode 100644 index 3aa2d0e..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/mgmt.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Managing Your Cat", - "description": "Look here for tips on how to manage your cat.", - "icon": "minecraft:string" -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/recipes.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/recipes.json deleted file mode 100644 index 106b759..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/categories/recipes.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Recipes", - "description": "Recipes for the items that are added by CatHerder.", - "icon": "minecraft:writable_book" -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/info.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/info.json deleted file mode 100644 index a61a665..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/info.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "Info", - "icon": "catherder:catnip", - "category": "catherder:mgmt", - "pages": [ - { - "type": "patchouli:text", - "text": "Once you've trained your cat, there are things you can do/use to manage your new friend." - }, - { - "type": "patchouli:spotlight", - "title": "String", - "text": "Right-click on your cat with string in your hand to open up the cat info screen. This screen has several sections.", - "item": { - "item": "minecraft:string" - } - }, - { - "type": "patchouli:text", - "title": "Talents", - "text": "On the left is a list of the talents you can assign to your pet. Next to the name of the talent are a pair of buttons for decreasing or increasing the number of points assigned to the talent. Hovering your mouse over either button will display a tooltip describing the talent and showing how many points are currently assigned.$(br2)You can only assign up to 5 points to a talent." - }, - { - "type": "patchouli:text", - "title": "Name and Mode", - "text": "In the center of the screen is a text field that lets you give a name to your cat. Above it is a button that, when clicked, will cycle through the various modes you can put your cat in." - }, - { - "type": "patchouli:text", - "title": "Overhead Text", - "text": "Above your cat's head is some text that shows various things about your cat.$(br2)At the top is the mode, current hunger, and (optionally) gender. Below that is the name of the cat. If you hold the crouch key down, the hunger value will also show the maximum hunger after a slash, and below the name, the owner's name will be displayed." - }, - { - "type": "patchouli:text", - "title": "Options", - "text": "On the right is some text that shows other information about your cat. Below it are two option buttons that let you enable/disable 'friendly fire' (other players can hurt your cat) and 'obey others' (other players can give your pet instructions/commands)." - } - ] -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/modes.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/modes.json deleted file mode 100644 index 7ad482a..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/mgmt/modes.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "Modes", - "icon": "catherder:cat_gut", - "category": "catherder:mgmt", - "pages": [ - { - "type": "patchouli:text", - "text": "In the info screen chapter, you learned that you can assign modes to your cat. They will be discussed in further detail here." - }, - { - "type": "patchouli:text", - "title": "Docile", - "text": "In this mode your cat will follow you but not attack anything. But you can always toss some toys around." - }, - { - "type": "patchouli:text", - "title": "Wandering", - "text": "In this mode, your cat will wander the world freely.$(br2)You may want to put a radio collar on your cat first.... Jus' sayin'." - }, - { - "type": "patchouli:text", - "title": "Attack", - "text": "In this mode, your cat will follow you and attack anything that attacks you or that you attack." - }, - { - "type": "patchouli:text", - "title": "Tactical", - "text": "In this mode, your cat will follow you but will not attack anything unless you use the command beam." - }, - { - "type": "patchouli:text", - "title": "Domestic", - "text": "In this mode, your cat will stay near its bowl, litterbox, and cat tree." - }, - { - "type": "patchouli:text", - "title": "Guard", - "text": "Cats follow closely and attack any monsters that come close." - }, - { - "type": "patchouli:text", - "title": "Skittish", - "text": "The cat will avoid all other creatures, and sometimes its owner.$(br2)You can configure how skittish your cats are in the client configuration." - } - ] -} diff --git a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/recipes/mods.json b/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/recipes/mods.json deleted file mode 100644 index 3176db2..0000000 --- a/src/main/resources/data/crafttracker/patchouli_books/tracking_crafts/en_us/entries/recipes/mods.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "Modifications", - "icon": "catherder:big_catsizer", - "category": "catherder:recipes", - "sortnum": 3, - "pages": [ - { - "type": "patchouli:text", - "text": "If you want to alter the size of your cat, this is the place to look." - }, - { - "type": "patchouli:crafting", - "title": "Shears", - "text": "Use these to remove a collar from your cat. Can also be used to reset the owner of a cat tree.", - "recipe": "catherder:collar_shears" - }, - { - "type": "patchouli:crafting", - "title": "Enlarger", - "text": "It's huge!", - "recipe": "catherder:big_catsizer" - }, - { - "type": "patchouli:crafting", - "title": "Shrinker", - "text": "Eat me...", - "recipe": "catherder:small_catsizer" - } - ] -} diff --git a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/cloche/catnip.json b/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/cloche/catnip.json deleted file mode 100644 index b40bb4a..0000000 --- a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/cloche/catnip.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "conditions": [ - { - "type": "forge:mod_loaded", - "modid": "immersiveengineering" - } - ], - "type": "immersiveengineering:cloche", - "results": [ - { - "item": "catherder:catnip", - "count": 2 - }, - { - "item": "catherder:catnip_seeds" - } - ], - "input": { - "item": "catherder:catnip_seeds" - }, - "soil": { - "item": "minecraft:dirt" - }, - "time": 800, - "render": { - "type": "crop", - "block": "catherder:catnip" - } -} diff --git a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/crusher/wild_catnip.json b/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/crusher/wild_catnip.json deleted file mode 100644 index 2def3c5..0000000 --- a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/crusher/wild_catnip.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "conditions": [ - { - "type": "forge:mod_loaded", - "modid": "immersiveengineering" - } - ], - "type": "immersiveengineering:crusher", - "secondaries": [ - { - "chance": 1.0, - "output": { - "item": "minecraft:yellow_dye", - "count": 1 - } - } - ], - "result": { - "base_ingredient": { - "item": "catherder:catnip_seeds" - } - }, - "input": { - "item": "catherder:wild_catnip" - }, - "energy": 3200 -} diff --git a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/squeezer/catnip_seeds.json b/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/squeezer/catnip_seeds.json deleted file mode 100644 index 70ae055..0000000 --- a/src/main/resources/data/crafttracker/recipes/integration/immersiveengineering/squeezer/catnip_seeds.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "conditions": [ - { - "type": "forge:mod_loaded", - "modid": "immersiveengineering" - } - ], - "type": "immersiveengineering:squeezer", - "fluid": { - "fluid": "immersiveengineering:plantoil", - "amount": 80 - }, - "input": { - "item": "catherder:catnip_seeds" - }, - "energy": 6400 -} From 0105e7ba6c09828555ee4636f92ff93fb97a836d Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Thu, 5 Dec 2024 21:20:15 -0800 Subject: [PATCH 4/8] Advancements --- .../assets/crafttracker/lang/de_de.json | 12 +++ .../assets/crafttracker/lang/en_gb.json | 12 +++ .../assets/crafttracker/lang/en_us.json | 12 +++ .../client/event/ClientEventHandler.java | 8 ++ .../client/screen/QueueManagementScreen.java | 6 ++ .../crafttracker/common/CommonSetup.java | 4 + .../advancement/CriterionTriggerBase.java | 76 ++++++++++++++ .../common/advancement/SimpleTrigger.java | 47 +++++++++ .../common/event/EventHandler.java | 8 ++ .../crafttracker/common/lib/Constants.java | 13 ++- .../common/network/PacketHandler.java | 3 + .../network/packet/AdvancementPacket.java | 37 +++++++ .../network/packet/data/AdvancementData.java | 12 +++ .../common/registry/ModAdvancements.java | 98 +++++++++++++++++++ .../common/registry/ModTriggers.java | 29 ++++++ .../common/util/AdvancementUtil.java | 21 ++++ .../data/CTAdvancementProvider.java | 17 ++-- .../crafttracker/data/CTLangProvider.java | 39 ++++++++ 18 files changed, 442 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/advancement/CriterionTriggerBase.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/advancement/SimpleTrigger.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/AdvancementPacket.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AdvancementData.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/registry/ModTriggers.java create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/util/AdvancementUtil.java diff --git a/src/generated/resources/assets/crafttracker/lang/de_de.json b/src/generated/resources/assets/crafttracker/lang/de_de.json index 9bf89e8..3a48e94 100644 --- a/src/generated/resources/assets/crafttracker/lang/de_de.json +++ b/src/generated/resources/assets/crafttracker/lang/de_de.json @@ -1,4 +1,16 @@ { + "advancements.crafttracker.main.acquire_list_item.description": "Einen Artikel erwerben, der auf der Einkaufsliste steht", + "advancements.crafttracker.main.acquire_list_item.title": "Einfach weiter einkaufen", + "advancements.crafttracker.main.clear_queue.description": "Leeren Sie die Herstellungswarteschlange vollst\u00E4ndig.", + "advancements.crafttracker.main.clear_queue.title": "Wie ein Boss", + "advancements.crafttracker.main.craft_item.description": "Einen in der Warteschlange befindlichen Gegenstand herstellen", + "advancements.crafttracker.main.craft_item.title": "Arbeiten", + "advancements.crafttracker.main.populate_list.description": "Die Einkaufsliste f\u00FCllen", + "advancements.crafttracker.main.populate_list.title": "To-do-Liste", + "advancements.crafttracker.main.queue_item.description": "Einen Gegenstand zur Herstellungswarteschlange hinzuf\u00FCgen", + "advancements.crafttracker.main.queue_item.title": "Denken Sie daran", + "advancements.crafttracker.main.root.description": "Behalten Sie den \u00DCberblick \u00FCber alle Dinge, die Sie zum Herstellen ben\u00F6tigen", + "advancements.crafttracker.main.root.title": "Tracking-Handwerk", "crafttracker.config.client.craft_queue_height": "Die H\u00F6he der Craft-Warteschlangen\u00FCberlagerung", "crafttracker.config.client.craft_queue_hide_empty": "Soll das Overlay der Herstellungswarteschlange ausgeblendet werden, wenn es leer ist?", "crafttracker.config.client.craft_queue_width": "Die Breite der Craft-Warteschlangen\u00FCberlagerung", diff --git a/src/generated/resources/assets/crafttracker/lang/en_gb.json b/src/generated/resources/assets/crafttracker/lang/en_gb.json index 6cc48ee..7745202 100644 --- a/src/generated/resources/assets/crafttracker/lang/en_gb.json +++ b/src/generated/resources/assets/crafttracker/lang/en_gb.json @@ -1,4 +1,16 @@ { + "advancements.crafttracker.main.acquire_list_item.description": "Acquire an item that is in the shopping list", + "advancements.crafttracker.main.acquire_list_item.title": "Just Keep Shopping", + "advancements.crafttracker.main.clear_queue.description": "Clear the crafting queue entirely", + "advancements.crafttracker.main.clear_queue.title": "Like A Boss", + "advancements.crafttracker.main.craft_item.description": "Craft a queued item", + "advancements.crafttracker.main.craft_item.title": "Workin'", + "advancements.crafttracker.main.populate_list.description": "Populate the shopping list", + "advancements.crafttracker.main.populate_list.title": "Honey-do List", + "advancements.crafttracker.main.queue_item.description": "Add an item to the crafting queue", + "advancements.crafttracker.main.queue_item.title": "Remember This", + "advancements.crafttracker.main.root.description": "Keep track of all the things you need to craft", + "advancements.crafttracker.main.root.title": "Tracking Crafts", "crafttracker.config.client.craft_queue_height": "The height of the craft queue overlay", "crafttracker.config.client.craft_queue_hide_empty": "Should the craft queue overlay be hidden when it is empty?", "crafttracker.config.client.craft_queue_width": "The width of the craft queue overlay", diff --git a/src/generated/resources/assets/crafttracker/lang/en_us.json b/src/generated/resources/assets/crafttracker/lang/en_us.json index 6cc48ee..7745202 100644 --- a/src/generated/resources/assets/crafttracker/lang/en_us.json +++ b/src/generated/resources/assets/crafttracker/lang/en_us.json @@ -1,4 +1,16 @@ { + "advancements.crafttracker.main.acquire_list_item.description": "Acquire an item that is in the shopping list", + "advancements.crafttracker.main.acquire_list_item.title": "Just Keep Shopping", + "advancements.crafttracker.main.clear_queue.description": "Clear the crafting queue entirely", + "advancements.crafttracker.main.clear_queue.title": "Like A Boss", + "advancements.crafttracker.main.craft_item.description": "Craft a queued item", + "advancements.crafttracker.main.craft_item.title": "Workin'", + "advancements.crafttracker.main.populate_list.description": "Populate the shopping list", + "advancements.crafttracker.main.populate_list.title": "Honey-do List", + "advancements.crafttracker.main.queue_item.description": "Add an item to the crafting queue", + "advancements.crafttracker.main.queue_item.title": "Remember This", + "advancements.crafttracker.main.root.description": "Keep track of all the things you need to craft", + "advancements.crafttracker.main.root.title": "Tracking Crafts", "crafttracker.config.client.craft_queue_height": "The height of the craft queue overlay", "crafttracker.config.client.craft_queue_hide_empty": "Should the craft queue overlay be hidden when it is empty?", "crafttracker.config.client.craft_queue_width": "The width of the craft queue overlay", diff --git a/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java b/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java index 06f9214..76bd023 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java @@ -7,6 +7,9 @@ import com.sweetrpg.crafttracker.common.lib.Constants; import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager; import com.sweetrpg.crafttracker.common.manager.ShoppingListManager; +import com.sweetrpg.crafttracker.common.network.PacketHandler; +import com.sweetrpg.crafttracker.common.network.packet.data.AdvancementData; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; import com.sweetrpg.crafttracker.common.registry.ModKeyBindings; import com.sweetrpg.crafttracker.common.util.InventoryUtil; import com.sweetrpg.crafttracker.common.util.KeyUtil; @@ -137,6 +140,8 @@ private static void handlePopulateShoppingList() { if(needed > 0) sMgr.addItem(player, f.getItemId(), needed); }); + + PacketHandler.sendToServer(new AdvancementData(ModAdvancements.Key.POPULATE_LIST)); } private static void handleToggleShoppingList() { @@ -179,6 +184,9 @@ private static void handleAddToQueue() { var player = Minecraft.getInstance().player; CraftingQueueManager.INSTANCE.addProduct(player, res, 1); + + // send advancement packet + PacketHandler.sendToServer(new AdvancementData(ModAdvancements.Key.QUEUE_ITEM)); } }); } diff --git a/src/main/java/com/sweetrpg/crafttracker/client/screen/QueueManagementScreen.java b/src/main/java/com/sweetrpg/crafttracker/client/screen/QueueManagementScreen.java index 068890b..42c6976 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/screen/QueueManagementScreen.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/screen/QueueManagementScreen.java @@ -7,6 +7,9 @@ import com.sweetrpg.crafttracker.common.lib.Constants; import com.sweetrpg.crafttracker.common.manager.CraftingQueueManager; import com.sweetrpg.crafttracker.common.model.CraftingQueueProduct; +import com.sweetrpg.crafttracker.common.network.PacketHandler; +import com.sweetrpg.crafttracker.common.network.packet.data.AdvancementData; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; import mezz.jei.api.constants.VanillaTypes; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; @@ -165,6 +168,9 @@ public void renderToolTip(PoseStack pPoseStack, int pMouseX, int pMouseY) { CraftingQueueManager.INSTANCE.removeAll(); QueueManagementScreen.this.productItems = CraftingQueueManager.INSTANCE.getEndProducts(); this.renderables.clear(); + + // send advancement packet + PacketHandler.sendToServer(new AdvancementData(ModAdvancements.Key.CLEAR_QUEUE)); }) /*{ @Override public void renderToolTip(PoseStack pPoseStack, int pMouseX, int pMouseY) { diff --git a/src/main/java/com/sweetrpg/crafttracker/common/CommonSetup.java b/src/main/java/com/sweetrpg/crafttracker/common/CommonSetup.java index 7b55570..a6b7f2a 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/CommonSetup.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/CommonSetup.java @@ -1,6 +1,8 @@ package com.sweetrpg.crafttracker.common; import com.sweetrpg.crafttracker.common.network.PacketHandler; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; +import com.sweetrpg.crafttracker.common.registry.ModTriggers; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; public class CommonSetup { @@ -8,6 +10,8 @@ public class CommonSetup { public static void init(final FMLCommonSetupEvent event) { event.enqueueWork(() -> { PacketHandler.init(); + ModAdvancements.register(); + ModTriggers.register(); }); } diff --git a/src/main/java/com/sweetrpg/crafttracker/common/advancement/CriterionTriggerBase.java b/src/main/java/com/sweetrpg/crafttracker/common/advancement/CriterionTriggerBase.java new file mode 100644 index 0000000..2bbcf19 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/advancement/CriterionTriggerBase.java @@ -0,0 +1,76 @@ +package com.sweetrpg.crafttracker.common.advancement; + +import com.google.common.collect.Maps; +import com.sweetrpg.crafttracker.common.util.Util; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.advancements.CriterionTrigger; +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.PlayerAdvancements; +import net.minecraft.server.level.ServerPlayer; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.*; +import java.util.function.Supplier; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public abstract class CriterionTriggerBase implements CriterionTrigger { + private final ResourceLocation id; + protected final Map>> listeners = Maps.newHashMap(); + + public CriterionTriggerBase(String id) { + this.id = Util.getResource(id); + } + + public void addPlayerListener(PlayerAdvancements playerAdvancementsIn, CriterionTrigger.Listener listener) { + Set> playerListeners = (Set) this.listeners.computeIfAbsent(playerAdvancementsIn, (k) -> new HashSet()); + playerListeners.add(listener); + } + + public void removePlayerListener(PlayerAdvancements playerAdvancementsIn, CriterionTrigger.Listener listener) { + Set> playerListeners = (Set) this.listeners.get(playerAdvancementsIn); + if(playerListeners != null) { + playerListeners.remove(listener); + if(playerListeners.isEmpty()) { + this.listeners.remove(playerAdvancementsIn); + } + } + + } + + public void removePlayerListeners(PlayerAdvancements playerAdvancementsIn) { + this.listeners.remove(playerAdvancementsIn); + } + + public ResourceLocation getId() { + return this.id; + } + + protected void trigger(ServerPlayer player, @Nullable List> suppliers) { + PlayerAdvancements playerAdvancements = player.getAdvancements(); + Set> playerListeners = (Set) this.listeners.get(playerAdvancements); + if(playerListeners != null) { + List> list = new LinkedList(); + + for(CriterionTrigger.Listener listener : playerListeners) { + if(((Instance) listener.getTriggerInstance()).test(suppliers)) { + list.add(listener); + } + } + + list.forEach((listenerx) -> listenerx.run(playerAdvancements)); + } + + } + + public abstract static class Instance extends AbstractCriterionTriggerInstance { + public Instance(ResourceLocation idIn, EntityPredicate.Composite p_i231464_2_) { + super(idIn, p_i231464_2_); + } + + protected abstract boolean test(@Nullable List> var1); + } +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/advancement/SimpleTrigger.java b/src/main/java/com/sweetrpg/crafttracker/common/advancement/SimpleTrigger.java new file mode 100644 index 0000000..e1f5491 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/advancement/SimpleTrigger.java @@ -0,0 +1,47 @@ +package com.sweetrpg.crafttracker.common.advancement; + +import com.google.gson.JsonObject; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.advancements.critereon.DeserializationContext; +import net.minecraft.advancements.critereon.EntityPredicate.Composite; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.List; +import java.util.function.Supplier; + + +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +public class SimpleTrigger extends CriterionTriggerBase { + + public static final String MAIN_CRITERION = "main"; + + public SimpleTrigger(String id) { + super(id); + } + + public Instance createInstance(JsonObject json, DeserializationContext context) { + return new Instance(this.getId()); + } + + public void trigger(ServerPlayer player) { + super.trigger(player, (List) null); + } + + public Instance instance() { + return new Instance(this.getId()); + } + + public static class Instance extends CriterionTriggerBase.Instance { + public Instance(ResourceLocation idIn) { + super(idIn, Composite.ANY); + } + + protected boolean test(@Nullable List> suppliers) { + return true; + } + } +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java b/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java index 216990d..e31e4f4 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java @@ -5,6 +5,8 @@ import com.sweetrpg.crafttracker.common.lib.Constants; import com.sweetrpg.crafttracker.common.network.PacketHandler; import com.sweetrpg.crafttracker.common.network.packet.data.QueueCommandData; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; +import com.sweetrpg.crafttracker.common.util.AdvancementUtil; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.EntityJoinWorldEvent; @@ -48,6 +50,8 @@ public void onItemCrafted(final ItemCraftedEvent event) { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); } + + AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } @SubscribeEvent @@ -65,6 +69,8 @@ public void onItemSmelted(final ItemSmeltedEvent event) { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); } + + AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } @SubscribeEvent @@ -82,6 +88,8 @@ public void onItemPickedUp(final ItemPickupEvent event) { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); } + + AdvancementUtil.trigger(ModAdvancements.Key.ACQUIRE_ITEM, (ServerPlayer) event.getPlayer()); } } diff --git a/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java b/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java index f650a86..5fe3269 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java @@ -68,10 +68,17 @@ public class Constants { public static final String TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HIDE_EMPTY = "crafttracker.config.client.shopping_list_hide_empty"; // Advancements + public static final String TRANSLATION_KEY_ADVANCEMENT_ROOT_TITLE = "advancements.crafttracker.main.root.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_ROOT_DESCRIPTION = "advancements.crafttracker.main.root.description"; public static final String TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_TITLE = "advancements.crafttracker.main.queue_item.title"; public static final String TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_DESCRIPTION = "advancements.crafttracker.main.queue_item.description"; - // TODO: craft an item in the queue - // TODO: populate the shopping list - // TODO: acquire something in the shopping list + public static final String TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_TITLE = "advancements.crafttracker.main.craft_item.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_DESCRIPTION = "advancements.crafttracker.main.craft_item.description"; + public static final String TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_TITLE = "advancements.crafttracker.main.populate_list.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_DESCRIPTION = "advancements.crafttracker.main.populate_list.description"; + public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE = "advancements.crafttracker.main.acquire_list_item.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION = "advancements.crafttracker.main.acquire_list_item.description"; + public static final String TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_TITLE = "advancements.crafttracker.main.clear_queue.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_DESCRIPTION = "advancements.crafttracker.main.clear_queue.description"; } diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/PacketHandler.java b/src/main/java/com/sweetrpg/crafttracker/common/network/PacketHandler.java index e43a32a..2418a3b 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/network/PacketHandler.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/network/PacketHandler.java @@ -1,7 +1,9 @@ package com.sweetrpg.crafttracker.common.network; import com.sweetrpg.crafttracker.CraftTracker; +import com.sweetrpg.crafttracker.common.network.packet.AdvancementPacket; import com.sweetrpg.crafttracker.common.network.packet.QueueCommandPacket; +import com.sweetrpg.crafttracker.common.network.packet.data.AdvancementData; import com.sweetrpg.crafttracker.common.network.packet.data.QueueCommandData; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.network.PacketDistributor; @@ -12,6 +14,7 @@ public final class PacketHandler { public static void init() { registerPacket(new QueueCommandPacket(), QueueCommandData.class); + registerPacket(new AdvancementPacket(), AdvancementData.class); } public static void sendToServer(MSG message) { diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AdvancementPacket.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AdvancementPacket.java new file mode 100644 index 0000000..2ed9433 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/AdvancementPacket.java @@ -0,0 +1,37 @@ +package com.sweetrpg.crafttracker.common.network.packet; + +import com.sweetrpg.crafttracker.CraftTracker; +import com.sweetrpg.crafttracker.common.network.IPacket; +import com.sweetrpg.crafttracker.common.network.packet.data.AdvancementData; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; +import com.sweetrpg.crafttracker.common.util.AdvancementUtil; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.network.NetworkEvent; + +import java.util.function.Supplier; + +public class AdvancementPacket implements IPacket { + + @Override + public void encode(AdvancementData data, FriendlyByteBuf buf) { + buf.writeEnum(data.advancement); + } + + @Override + public AdvancementData decode(FriendlyByteBuf buf) { + var advancement = buf.readEnum(ModAdvancements.Key.class); + return new AdvancementData(advancement); + } + + @Override + public final void handle(AdvancementData data, Supplier ctx) { + CraftTracker.LOGGER.debug("AdvancementPacket#handle: {}", data); + + ctx.get().enqueueWork(() -> { + AdvancementUtil.trigger(data.advancement, ctx.get().getSender()); + }); + + ctx.get().setPacketHandled(true); + } + +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AdvancementData.java b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AdvancementData.java new file mode 100644 index 0000000..740fd17 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/network/packet/data/AdvancementData.java @@ -0,0 +1,12 @@ +package com.sweetrpg.crafttracker.common.network.packet.data; + +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; + +public class AdvancementData { + + public ModAdvancements.Key advancement; + + public AdvancementData(ModAdvancements.Key advancement) { + this.advancement = advancement; + } +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java new file mode 100644 index 0000000..b43e8e0 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java @@ -0,0 +1,98 @@ +package com.sweetrpg.crafttracker.common.registry; + +import com.sweetrpg.crafttracker.common.util.Util; +import com.sweetrpg.crafttracker.data.DisplayInfoBuilder; +import net.minecraft.advancements.Advancement; +import net.minecraft.advancements.FrameType; +import net.minecraft.advancements.RequirementsStrategy; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.advancements.critereon.TickTrigger; +import net.minecraft.world.item.Items; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +import static com.sweetrpg.crafttracker.common.advancement.SimpleTrigger.MAIN_CRITERION; + +public class ModAdvancements { + public static final Map ENTRIES = new HashMap<>(); + public static final Advancement START = null; + public static final Advancement ROOT = create("root", Key.ROOT, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.PAPER) + .frame(FrameType.TASK) + .translate("crafttracker.main.root") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, new TickTrigger.TriggerInstance(EntityPredicate.Composite.ANY)) + .requirements(RequirementsStrategy.OR)); + public static final Advancement QUEUE_ITEM = create("queue_item", Key.QUEUE_ITEM, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.PAPER) + .frame(FrameType.TASK) + .translate("crafttracker.main.queue_item") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("queue_item").instance()) + .requirements(RequirementsStrategy.OR)); + public static final Advancement CRAFT_ITEM = create("craft_item", Key.CRAFT_ITEM, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.CRAFTING_TABLE) + .frame(FrameType.TASK) + .translate("crafttracker.main.craft_item") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("craft_item").instance()) +// .parent(QUEUE_ITEM) + .requirements(RequirementsStrategy.OR)); + public static final Advancement POPULATE_LIST = create("populate_list", Key.POPULATE_LIST, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.PAPER) + .frame(FrameType.TASK) + .translate("crafttracker.main.populate_list") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("populate_list").instance()) + .requirements(RequirementsStrategy.OR)); + public static final Advancement ACQUIRE_ITEM = create("acquire_item", Key.ACQUIRE_ITEM, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.CRAFTING_TABLE) + .frame(FrameType.TASK) + .translate("crafttracker.main.acquire_item") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("acquire_item").instance()) +// .parent(POPULATE_LIST) + .requirements(RequirementsStrategy.OR)); + public static final Advancement CLEAR_QUEUE = create("clear_queue", Key.CLEAR_QUEUE, () -> Advancement.Builder.advancement() + .display(DisplayInfoBuilder.create() + .icon(Items.CRAFTING_TABLE) + .frame(FrameType.TASK) + .translate("crafttracker.main.clear_queue") + .background("stone.png") + .build()) + .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("clear_queue").instance()) +// .parent(QUEUE_ITEM) + .requirements(RequirementsStrategy.OR)); + + + public static Advancement create(final String name, Key key, Supplier sup) { + var adv = sup.get().build(Util.getResource(name)); + ModAdvancements.ENTRIES.put(key, adv); + return adv; + } + + public static void register() { + } + + public enum Key { + ROOT, + QUEUE_ITEM, + CRAFT_ITEM, + POPULATE_LIST, + ACQUIRE_ITEM, + CLEAR_QUEUE, + } + +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/registry/ModTriggers.java b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModTriggers.java new file mode 100644 index 0000000..df4f4da --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModTriggers.java @@ -0,0 +1,29 @@ +package com.sweetrpg.crafttracker.common.registry; + +import com.sweetrpg.crafttracker.common.advancement.CriterionTriggerBase; +import com.sweetrpg.crafttracker.common.advancement.SimpleTrigger; +import net.minecraft.advancements.CriteriaTriggers; + +import java.util.HashMap; +import java.util.Map; + +public class ModTriggers { + + public static final Map> ENTRIES = new HashMap<>(); + + public ModTriggers() { + } + + public static SimpleTrigger addSimple(String id) { + return (SimpleTrigger) add(id, new SimpleTrigger(id)); + } + + private static > T add(String name, T instance) { + ENTRIES.put(name, instance); + return instance; + } + + public static void register() { + ENTRIES.values().forEach(CriteriaTriggers::register); + } +} diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/AdvancementUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/AdvancementUtil.java new file mode 100644 index 0000000..f6f44b9 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/AdvancementUtil.java @@ -0,0 +1,21 @@ +package com.sweetrpg.crafttracker.common.util; + +import com.sweetrpg.crafttracker.common.advancement.SimpleTrigger; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; +import com.sweetrpg.crafttracker.common.registry.ModTriggers; +import net.minecraft.server.level.ServerPlayer; + +import static com.sweetrpg.crafttracker.common.advancement.SimpleTrigger.MAIN_CRITERION; + +public class AdvancementUtil { + + public static void trigger(ModAdvancements.Key advancement, ServerPlayer player) { + var ct = ModAdvancements.ENTRIES.get(advancement) + .getCriteria().get(MAIN_CRITERION) + .getTrigger(); + if(ModTriggers.ENTRIES.get(ct.getCriterion().getPath()) instanceof SimpleTrigger trigger) { + trigger.trigger(player); + } + + } +} diff --git a/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java b/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java index 75c7dcf..b6e10c5 100644 --- a/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java +++ b/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java @@ -3,6 +3,8 @@ import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.sweetrpg.crafttracker.common.registry.ModAdvancements; +import com.sweetrpg.crafttracker.common.util.Util; import net.minecraft.advancements.Advancement; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; @@ -57,14 +59,11 @@ public void run(HashCache cache) { } }; - // tracking -// Advancement trainCat = Advancement.Builder.advancement() -//// .parent(Util.mcLoc("tame_animal")) -// .display(DisplayInfoBuilder.create().icon(ModItems.TRAINING_TREAT).frame(FrameType.TASK).translate("CraftTracker.main.train_cat").background("stone.png").build()) -// .addCriterion("tame_cat", TameAnimalTrigger.TriggerInstance.tamedAnimal(EntityPredicate.Builder.entity().of(ModEntityTypes.CAT.get()).build())) -// //.withCriterion("get_cat", ItemUseTrigger.TameAnimalTrigger.Instance.create(EntityPredicate.Builder.create().type(CatEntityTypes.CAT.get()).build())) -// .requirements(RequirementsStrategy.OR) -// .save(consumer, Util.getResourcePath("main/tame_cat")); - + var root = ModAdvancements.ROOT.deconstruct().save(consumer, Util.getResourcePath("main/root")); + var queueItem = ModAdvancements.QUEUE_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/queue_item")); + var craftItem = ModAdvancements.CRAFT_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/craft_item")); + var populateList = ModAdvancements.POPULATE_LIST.deconstruct().save(consumer, Util.getResourcePath("main/populate_list")); + var acquireItem = ModAdvancements.ACQUIRE_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/acquire_item")); + var clearQueue = ModAdvancements.CLEAR_QUEUE.deconstruct().save(consumer, Util.getResourcePath("main/clear_queue")); } } diff --git a/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java b/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java index c7c4069..873d784 100644 --- a/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java +++ b/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java @@ -70,6 +70,19 @@ private void processENUS() { add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HEIGHT, "The height of the shopping list overlay"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_CRAFT_QUEUE_HIDE_EMPTY, "Should the craft queue overlay be hidden when it is empty?"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HIDE_EMPTY, "Should the shopping list overlay be hidden when it is empty?"); + + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_TITLE, "Tracking Crafts"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_DESCRIPTION, "Keep track of all the things you need to craft"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_TITLE, "Remember This"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_DESCRIPTION, "Add an item to the crafting queue"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_TITLE, "Workin'"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_DESCRIPTION, "Craft a queued item"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_TITLE, "Honey-do List"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_DESCRIPTION, "Populate the shopping list"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE, "Just Keep Shopping"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION, "Acquire an item that is in the shopping list"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_TITLE, "Like A Boss"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_DESCRIPTION, "Clear the crafting queue entirely"); } private void processENGB() { @@ -115,6 +128,19 @@ private void processENGB() { add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HEIGHT, "The height of the shopping list overlay"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_CRAFT_QUEUE_HIDE_EMPTY, "Should the craft queue overlay be hidden when it is empty?"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HIDE_EMPTY, "Should the shopping list overlay be hidden when it is empty?"); + + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_TITLE, "Tracking Crafts"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_DESCRIPTION, "Keep track of all the things you need to craft"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_TITLE, "Remember This"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_DESCRIPTION, "Add an item to the crafting queue"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_TITLE, "Workin'"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_DESCRIPTION, "Craft a queued item"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_TITLE, "Honey-do List"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_DESCRIPTION, "Populate the shopping list"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE, "Just Keep Shopping"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION, "Acquire an item that is in the shopping list"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_TITLE, "Like A Boss"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_DESCRIPTION, "Clear the crafting queue entirely"); } private void processDEDE() { @@ -160,5 +186,18 @@ private void processDEDE() { add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HEIGHT, "Die Höhe des Einkaufslisten-Overlays"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_CRAFT_QUEUE_HIDE_EMPTY, "Soll das Overlay der Herstellungswarteschlange ausgeblendet werden, wenn es leer ist?"); add(Constants.TRANSLATION_KEY_CONFIG_CLIENT_SHOPPING_LIST_HIDE_EMPTY, "Soll das Einkaufslisten-Overlay ausgeblendet werden, wenn es leer ist?"); + + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_TITLE, "Tracking-Handwerk"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ROOT_DESCRIPTION, "Behalten Sie den Überblick über alle Dinge, die Sie zum Herstellen benötigen"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_TITLE, "Denken Sie daran"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_QUEUE_ITEM_DESCRIPTION, "Einen Gegenstand zur Herstellungswarteschlange hinzufügen"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_TITLE, "Arbeiten"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_DESCRIPTION, "Einen in der Warteschlange befindlichen Gegenstand herstellen"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_TITLE, "To-do-Liste"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_DESCRIPTION, "Die Einkaufsliste füllen"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE, "Einfach weiter einkaufen"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION, "Einen Artikel erwerben, der auf der Einkaufsliste steht"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_TITLE, "Wie ein Boss"); + add(Constants.TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_DESCRIPTION, "Leeren Sie die Herstellungswarteschlange vollständig."); } } From 651b8fb991e84b03b6f493b94522df289f402042 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Thu, 5 Dec 2024 21:41:11 -0800 Subject: [PATCH 5/8] Parenting and bug fixes --- .../crafttracker/common/event/EventHandler.java | 9 +++------ .../sweetrpg/crafttracker/common/lib/Constants.java | 4 ++-- .../crafttracker/common/registry/ModAdvancements.java | 3 --- .../crafttracker/data/CTAdvancementProvider.java | 10 +++++----- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java b/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java index e31e4f4..0459a34 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/event/EventHandler.java @@ -49,9 +49,8 @@ public void onItemCrafted(final ItemCraftedEvent event) { else { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); + AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } - - AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } @SubscribeEvent @@ -68,9 +67,8 @@ public void onItemSmelted(final ItemSmeltedEvent event) { else { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); + AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } - - AdvancementUtil.trigger(ModAdvancements.Key.CRAFT_ITEM, (ServerPlayer) event.getPlayer()); } @SubscribeEvent @@ -87,9 +85,8 @@ public void onItemPickedUp(final ItemPickupEvent event) { else { // send packet PacketHandler.sendToPlayer((ServerPlayer) event.getPlayer(), new QueueCommandData(RECALCULATE)); + AdvancementUtil.trigger(ModAdvancements.Key.ACQUIRE_ITEM, (ServerPlayer) event.getPlayer()); } - - AdvancementUtil.trigger(ModAdvancements.Key.ACQUIRE_ITEM, (ServerPlayer) event.getPlayer()); } } diff --git a/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java b/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java index 5fe3269..841589b 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/lib/Constants.java @@ -76,8 +76,8 @@ public class Constants { public static final String TRANSLATION_KEY_ADVANCEMENT_CRAFT_ITEM_DESCRIPTION = "advancements.crafttracker.main.craft_item.description"; public static final String TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_TITLE = "advancements.crafttracker.main.populate_list.title"; public static final String TRANSLATION_KEY_ADVANCEMENT_POPULATE_SHOPPING_LIST_DESCRIPTION = "advancements.crafttracker.main.populate_list.description"; - public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE = "advancements.crafttracker.main.acquire_list_item.title"; - public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION = "advancements.crafttracker.main.acquire_list_item.description"; + public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_TITLE = "advancements.crafttracker.main.acquire_item.title"; + public static final String TRANSLATION_KEY_ADVANCEMENT_ACQUIRE_LIST_ITEM_DESCRIPTION = "advancements.crafttracker.main.acquire_item.description"; public static final String TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_TITLE = "advancements.crafttracker.main.clear_queue.title"; public static final String TRANSLATION_KEY_ADVANCEMENT_CLEAR_QUEUE_ITEM_DESCRIPTION = "advancements.crafttracker.main.clear_queue.description"; diff --git a/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java index b43e8e0..8d0c6cb 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/registry/ModAdvancements.java @@ -44,7 +44,6 @@ public class ModAdvancements { .background("stone.png") .build()) .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("craft_item").instance()) -// .parent(QUEUE_ITEM) .requirements(RequirementsStrategy.OR)); public static final Advancement POPULATE_LIST = create("populate_list", Key.POPULATE_LIST, () -> Advancement.Builder.advancement() .display(DisplayInfoBuilder.create() @@ -63,7 +62,6 @@ public class ModAdvancements { .background("stone.png") .build()) .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("acquire_item").instance()) -// .parent(POPULATE_LIST) .requirements(RequirementsStrategy.OR)); public static final Advancement CLEAR_QUEUE = create("clear_queue", Key.CLEAR_QUEUE, () -> Advancement.Builder.advancement() .display(DisplayInfoBuilder.create() @@ -73,7 +71,6 @@ public class ModAdvancements { .background("stone.png") .build()) .addCriterion(MAIN_CRITERION, ModTriggers.addSimple("clear_queue").instance()) -// .parent(QUEUE_ITEM) .requirements(RequirementsStrategy.OR)); diff --git a/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java b/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java index b6e10c5..3b04f1f 100644 --- a/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java +++ b/src/main/java/com/sweetrpg/crafttracker/data/CTAdvancementProvider.java @@ -60,10 +60,10 @@ public void run(HashCache cache) { }; var root = ModAdvancements.ROOT.deconstruct().save(consumer, Util.getResourcePath("main/root")); - var queueItem = ModAdvancements.QUEUE_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/queue_item")); - var craftItem = ModAdvancements.CRAFT_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/craft_item")); - var populateList = ModAdvancements.POPULATE_LIST.deconstruct().save(consumer, Util.getResourcePath("main/populate_list")); - var acquireItem = ModAdvancements.ACQUIRE_ITEM.deconstruct().save(consumer, Util.getResourcePath("main/acquire_item")); - var clearQueue = ModAdvancements.CLEAR_QUEUE.deconstruct().save(consumer, Util.getResourcePath("main/clear_queue")); + var queueItem = ModAdvancements.QUEUE_ITEM.deconstruct().parent(root).save(consumer, Util.getResourcePath("main/queue_item")); + var craftItem = ModAdvancements.CRAFT_ITEM.deconstruct().parent(queueItem).save(consumer, Util.getResourcePath("main/craft_item")); + var populateList = ModAdvancements.POPULATE_LIST.deconstruct().parent(root).save(consumer, Util.getResourcePath("main/populate_list")); + var acquireItem = ModAdvancements.ACQUIRE_ITEM.deconstruct().parent(populateList).save(consumer, Util.getResourcePath("main/acquire_item")); + var clearQueue = ModAdvancements.CLEAR_QUEUE.deconstruct().parent(queueItem).save(consumer, Util.getResourcePath("main/clear_queue")); } } From 9adc55fd07fc810023df191f732caf80d7651a83 Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Fri, 6 Dec 2024 05:42:38 +0000 Subject: [PATCH 6/8] Update 1.18 .release-info files --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index 0c62199..ee1372d 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 From 3682733e64a7f9f03d6c4011b5c72872fbc498e4 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Thu, 5 Dec 2024 21:45:58 -0800 Subject: [PATCH 7/8] Notes and the advancement files. --- CHANGELOG/1.18/current.md | 1 + .../advancements/main/acquire_item.json | 30 +++++++++++++++++++ .../advancements/main/clear_queue.json | 30 +++++++++++++++++++ .../advancements/main/craft_item.json | 30 +++++++++++++++++++ .../advancements/main/populate_list.json | 30 +++++++++++++++++++ .../advancements/main/queue_item.json | 30 +++++++++++++++++++ .../crafttracker/advancements/main/root.json | 29 ++++++++++++++++++ 7 files changed, 180 insertions(+) create mode 100644 src/generated/resources/data/crafttracker/advancements/main/acquire_item.json create mode 100644 src/generated/resources/data/crafttracker/advancements/main/clear_queue.json create mode 100644 src/generated/resources/data/crafttracker/advancements/main/craft_item.json create mode 100644 src/generated/resources/data/crafttracker/advancements/main/populate_list.json create mode 100644 src/generated/resources/data/crafttracker/advancements/main/queue_item.json create mode 100644 src/generated/resources/data/crafttracker/advancements/main/root.json diff --git a/CHANGELOG/1.18/current.md b/CHANGELOG/1.18/current.md index e69de29..e5cd83b 100644 --- a/CHANGELOG/1.18/current.md +++ b/CHANGELOG/1.18/current.md @@ -0,0 +1 @@ +- `[NEW]` Advancements! diff --git a/src/generated/resources/data/crafttracker/advancements/main/acquire_item.json b/src/generated/resources/data/crafttracker/advancements/main/acquire_item.json new file mode 100644 index 0000000..81eb9bd --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/acquire_item.json @@ -0,0 +1,30 @@ +{ + "parent": "crafttracker:main/populate_list", + "display": { + "icon": { + "item": "minecraft:crafting_table" + }, + "title": { + "translate": "advancements.crafttracker.main.acquire_item.title" + }, + "description": { + "translate": "advancements.crafttracker.main.acquire_item.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "crafttracker:acquire_item", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/crafttracker/advancements/main/clear_queue.json b/src/generated/resources/data/crafttracker/advancements/main/clear_queue.json new file mode 100644 index 0000000..1ddae0b --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/clear_queue.json @@ -0,0 +1,30 @@ +{ + "parent": "crafttracker:main/queue_item", + "display": { + "icon": { + "item": "minecraft:crafting_table" + }, + "title": { + "translate": "advancements.crafttracker.main.clear_queue.title" + }, + "description": { + "translate": "advancements.crafttracker.main.clear_queue.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "crafttracker:clear_queue", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/crafttracker/advancements/main/craft_item.json b/src/generated/resources/data/crafttracker/advancements/main/craft_item.json new file mode 100644 index 0000000..1ed10df --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/craft_item.json @@ -0,0 +1,30 @@ +{ + "parent": "crafttracker:main/queue_item", + "display": { + "icon": { + "item": "minecraft:crafting_table" + }, + "title": { + "translate": "advancements.crafttracker.main.craft_item.title" + }, + "description": { + "translate": "advancements.crafttracker.main.craft_item.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "crafttracker:craft_item", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/crafttracker/advancements/main/populate_list.json b/src/generated/resources/data/crafttracker/advancements/main/populate_list.json new file mode 100644 index 0000000..096daf8 --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/populate_list.json @@ -0,0 +1,30 @@ +{ + "parent": "crafttracker:main/root", + "display": { + "icon": { + "item": "minecraft:paper" + }, + "title": { + "translate": "advancements.crafttracker.main.populate_list.title" + }, + "description": { + "translate": "advancements.crafttracker.main.populate_list.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "crafttracker:populate_list", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/crafttracker/advancements/main/queue_item.json b/src/generated/resources/data/crafttracker/advancements/main/queue_item.json new file mode 100644 index 0000000..60a7607 --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/queue_item.json @@ -0,0 +1,30 @@ +{ + "parent": "crafttracker:main/root", + "display": { + "icon": { + "item": "minecraft:paper" + }, + "title": { + "translate": "advancements.crafttracker.main.queue_item.title" + }, + "description": { + "translate": "advancements.crafttracker.main.queue_item.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "crafttracker:queue_item", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/crafttracker/advancements/main/root.json b/src/generated/resources/data/crafttracker/advancements/main/root.json new file mode 100644 index 0000000..7499202 --- /dev/null +++ b/src/generated/resources/data/crafttracker/advancements/main/root.json @@ -0,0 +1,29 @@ +{ + "display": { + "icon": { + "item": "minecraft:paper" + }, + "title": { + "translate": "advancements.crafttracker.main.root.title" + }, + "description": { + "translate": "advancements.crafttracker.main.root.description" + }, + "frame": "task", + "show_toast": true, + "announce_to_chat": true, + "hidden": false, + "background": "minecraft:textures/gui/advancements/backgrounds/stone.png" + }, + "criteria": { + "main": { + "trigger": "minecraft:tick", + "conditions": {} + } + }, + "requirements": [ + [ + "main" + ] + ] +} \ No newline at end of file From 5946c3a63c6cdaab3e582eb661dda8dbe1300318 Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Fri, 6 Dec 2024 05:47:18 +0000 Subject: [PATCH 8/8] Update 1.18 .release-info files --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index ee1372d..7179039 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.2.2 +0.2.3