diff --git a/build_pack.sh b/build_pack.sh index ff854ee9..9424f906 100644 --- a/build_pack.sh +++ b/build_pack.sh @@ -1,10 +1,10 @@ #!/bin/bash readonly NAME_COLOR_FROM="#07c5fa" -readonly NAME_COLOR_TO="#dff2f7" +readonly NAME_COLOR_TO="#b2e8f7" -readonly VERSION_COLOR_MAJOR="#fd99b1" -readonly VERSION_COLOR_MINOR="#fee6a8" +readonly VERSION_COLOR_MAJOR="#f8c8dc" +readonly VERSION_COLOR_MINOR="#fac898" readonly VERSION_COLOR_PATCH="#e4adf7" readonly modId=$1 diff --git a/gradle.properties b/gradle.properties index f4209be6..589358d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.parallel=true author=diskree modName=AchieveToDo -modVersion=1.3 +modVersion=1.4 minJavaVersion=17 minecraftVersion=1.20.4 diff --git a/pack/index.toml b/pack/index.toml index cf823375..aaab03f6 100644 --- a/pack/index.toml +++ b/pack/index.toml @@ -68,7 +68,7 @@ metafile = true file = "icon.png" [[files]] -file = "mods/achievetodo-mc1.20.4+1.3.jar" +file = "mods/achievetodo-mc1.20.4+1.4.jar" [[files]] file = "mods/antighost.pw.toml" @@ -254,6 +254,10 @@ metafile = true file = "mods/textile-backup.pw.toml" metafile = true +[[files]] +file = "mods/xyzbook.pw.toml" +metafile = true + [[files]] file = "mods/yacl.pw.toml" metafile = true diff --git a/pack/mods/fixbookgui.pw.toml b/pack/mods/fixbookgui.pw.toml index b39f7bf0..27980127 100644 --- a/pack/mods/fixbookgui.pw.toml +++ b/pack/mods/fixbookgui.pw.toml @@ -1,13 +1,13 @@ name = "FixBookGUI" -filename = "fixbookgui-1.5.0+1.20.4.jar" +filename = "fixbookgui-1.6.0+1.20.4.jar" side = "client" [download] -url = "https://cdn.modrinth.com/data/myKgAJq6/versions/WuiUYZJH/fixbookgui-1.5.0%2B1.20.4.jar" +url = "https://cdn.modrinth.com/data/myKgAJq6/versions/5pg0WqAA/fixbookgui-1.6.0%2B1.20.4.jar" hash-format = "sha1" -hash = "13061142ab1fcbd87ed7b534f75910f431be2325" +hash = "b2f375edc03d23dc35b9cfe60cd480123a59c571" [update] [update.modrinth] mod-id = "myKgAJq6" -version = "WuiUYZJH" +version = "5pg0WqAA" diff --git a/pack/mods/xyzbook.pw.toml b/pack/mods/xyzbook.pw.toml new file mode 100644 index 00000000..9699e12e --- /dev/null +++ b/pack/mods/xyzbook.pw.toml @@ -0,0 +1,8 @@ +name = "XYZ Book" +filename = "xyzbook-mc1.20.4+1.0.jar" +side = "client" + +[download] +url = "https://github.com/diskree/XYZBook/releases/download/1.0/xyzbook-mc1.20.4+1.0.jar" +hash-format = "sha1" +hash = "fd295910285aa9bc00a74dcf17d43d0e2a83ebd8" diff --git a/src/main/java/com/diskree/achievetodo/action/BlockedActionType.java b/src/main/java/com/diskree/achievetodo/action/BlockedActionType.java index ecdcfc12..5a99ebb0 100644 --- a/src/main/java/com/diskree/achievetodo/action/BlockedActionType.java +++ b/src/main/java/com/diskree/achievetodo/action/BlockedActionType.java @@ -38,52 +38,52 @@ public enum BlockedActionType implements IGeneratedAdvancement { 30 ), USING_BOAT( - 80 + 82 ), USING_SHIELD( - 90, Items.SHIELD + 93, Items.SHIELD ), USING_WATER_BUCKET( - 130, Items.WATER_BUCKET + 135, Items.WATER_BUCKET ), USING_SHEARS( - 140, Items.SHEARS + 144, Items.SHEARS ), USING_CROSSBOW( - 150, Items.CROSSBOW + 178, Items.CROSSBOW ), BREAK_BLOCKS_IN_NEGATIVE_Y( - 200 + 206 ), USING_FISHING_ROD( - 220, Items.FISHING_ROD + 225, Items.FISHING_ROD ), USING_BOW( - 240, Items.BOW + 243, Items.BOW ), USING_BRUSH( - 260, Items.BRUSH + 261, Items.BRUSH ), USING_SPYGLASS( - 280, Items.SPYGLASS + 282, Items.SPYGLASS ), THROW_TRIDENT( - 300, Items.TRIDENT + 311, Items.TRIDENT ), THROW_ENDER_PEARL( - 330, Items.ENDER_PEARL + 334, Items.ENDER_PEARL ), EQUIP_ELYTRA( - 650 + 657 ), END_GATEWAY( - 675 + 679 ), FLY( - 725, Items.FIREWORK_ROCKET + 721, Items.FIREWORK_ROCKET ), OPEN_SHULKER_BOX( - 750 + 754 ), EAT_SALMON( @@ -111,191 +111,191 @@ public enum BlockedActionType implements IGeneratedAdvancement { 18, FoodComponents.PUFFERFISH ), EAT_POISONOUS_POTATO( - 20, FoodComponents.POISONOUS_POTATO + 22, FoodComponents.POISONOUS_POTATO ), EAT_CHORUS_FRUIT( - 25, FoodComponents.CHORUS_FRUIT + 27, FoodComponents.CHORUS_FRUIT ), EAT_SUSPICIOUS_STEW( - 30, FoodComponents.SUSPICIOUS_STEW + 32, FoodComponents.SUSPICIOUS_STEW ), EAT_BEETROOT( - 35, FoodComponents.BEETROOT + 38, FoodComponents.BEETROOT ), EAT_CARROT( - 40, FoodComponents.CARROT + 43, FoodComponents.CARROT ), EAT_CHICKEN( - 45, FoodComponents.CHICKEN + 47, FoodComponents.CHICKEN ), EAT_DRIED_KELP( - 50, FoodComponents.DRIED_KELP + 51, FoodComponents.DRIED_KELP ), EAT_BEETROOT_SOUP( - 60, FoodComponents.BEETROOT_SOUP + 68, FoodComponents.BEETROOT_SOUP ), EAT_POTATO( - 70, FoodComponents.POTATO + 71, FoodComponents.POTATO ), EAT_APPLE( - 80, FoodComponents.APPLE + 83, FoodComponents.APPLE ), EAT_MELON_SLICE( - 90, FoodComponents.MELON_SLICE + 95, FoodComponents.MELON_SLICE ), EAT_COOKIE( - 100, FoodComponents.COOKIE + 102, FoodComponents.COOKIE ), EAT_MUSHROOM_STEW( - 110, FoodComponents.MUSHROOM_STEW + 114, FoodComponents.MUSHROOM_STEW ), EAT_RABBIT_STEW( - 120, FoodComponents.RABBIT_STEW + 127, FoodComponents.RABBIT_STEW ), EAT_HONEY_BOTTLE( - 130, FoodComponents.HONEY_BOTTLE + 132, FoodComponents.HONEY_BOTTLE ), EAT_PUMPKIN_PIE( - 140, FoodComponents.PUMPKIN_PIE + 141, FoodComponents.PUMPKIN_PIE ), EAT_GOLDEN_APPLE( - 150, FoodComponents.GOLDEN_APPLE + 155, FoodComponents.GOLDEN_APPLE ), EAT_ENCHANTED_GOLDEN_APPLE( - 160, FoodComponents.ENCHANTED_GOLDEN_APPLE + 166, FoodComponents.ENCHANTED_GOLDEN_APPLE ), EAT_RABBIT( - 180, FoodComponents.RABBIT + 182, FoodComponents.RABBIT ), EAT_MUTTON( - 200, FoodComponents.MUTTON + 212, FoodComponents.MUTTON ), EAT_PORKCHOP( - 220, FoodComponents.PORKCHOP + 226, FoodComponents.PORKCHOP ), EAT_BEEF( - 240, FoodComponents.BEEF + 249, FoodComponents.BEEF ), EAT_BAKED_POTATO( - 250, FoodComponents.BAKED_POTATO + 252, FoodComponents.BAKED_POTATO ), EAT_COOKED_SALMON( - 300, FoodComponents.COOKED_SALMON + 312, FoodComponents.COOKED_SALMON ), EAT_COOKED_COD( - 350, FoodComponents.COOKED_COD + 373, FoodComponents.COOKED_COD ), EAT_COOKED_RABBIT( - 400, FoodComponents.COOKED_RABBIT + 432, FoodComponents.COOKED_RABBIT ), EAT_COOKED_CHICKEN( - 450, FoodComponents.COOKED_CHICKEN + 459, FoodComponents.COOKED_CHICKEN ), EAT_COOKED_MUTTON( - 500, FoodComponents.COOKED_MUTTON + 524, FoodComponents.COOKED_MUTTON ), EAT_COOKED_PORKCHOP( 550, FoodComponents.COOKED_PORKCHOP ), EAT_COOKED_BEEF( - 600, FoodComponents.COOKED_BEEF + 603, FoodComponents.COOKED_BEEF ), EAT_BREAD( - 650, FoodComponents.BREAD + 654, FoodComponents.BREAD ), EAT_GOLDEN_CARROT( - 700, FoodComponents.GOLDEN_CARROT + 702, FoodComponents.GOLDEN_CARROT ), OPEN_CHEST( - 30, Blocks.CHEST + 36, Blocks.CHEST ), USING_CRAFTING_TABLE( - 50, Blocks.CRAFTING_TABLE + 52, Blocks.CRAFTING_TABLE ), USING_STONECUTTER( - 75, Blocks.STONECUTTER + 78, Blocks.STONECUTTER ), OPEN_FURNACE( - 100, Blocks.FURNACE + 99, Blocks.FURNACE ), USING_ANVIL( - 150, Blocks.ANVIL + 103, Blocks.ANVIL ), USING_GRINDSTONE( - 175, Blocks.GRINDSTONE + 174, Blocks.GRINDSTONE ), USING_LOOM( - 200, Blocks.LOOM + 215, Blocks.LOOM ), OPEN_SMOKER( - 250, Blocks.SMOKER + 257, Blocks.SMOKER ), OPEN_BLAST_FURNACE( - 270, Blocks.BLAST_FURNACE + 272, Blocks.BLAST_FURNACE ), USING_CARTOGRAPHY_TABLE( - 300, Blocks.CARTOGRAPHY_TABLE + 304, Blocks.CARTOGRAPHY_TABLE ), OPEN_ENDER_CHEST( - 350, Blocks.ENDER_CHEST + 352, Blocks.ENDER_CHEST ), OPEN_BREWING_STAND( - 400, Blocks.BREWING_STAND + 409, Blocks.BREWING_STAND ), USING_SMITHING_TABLE( - 450, Blocks.SMITHING_TABLE + 453, Blocks.SMITHING_TABLE ), USING_BEACON( - 500, Blocks.BEACON + 505, Blocks.BEACON ), USING_ENCHANTING_TABLE( - 950, Blocks.ENCHANTING_TABLE + 937, Blocks.ENCHANTING_TABLE ), USING_GOLDEN_TOOLS( - 40, ToolMaterials.GOLD + 41, ToolMaterials.GOLD ), USING_WOODEN_TOOLS( - 60, ToolMaterials.WOOD + 63, ToolMaterials.WOOD ), USING_STONE_TOOLS( - 90, ToolMaterials.STONE + 97, ToolMaterials.STONE ), USING_IRON_TOOLS( - 120, ToolMaterials.IRON + 122, ToolMaterials.IRON ), USING_DIAMOND_TOOLS( - 350, ToolMaterials.DIAMOND + 358, ToolMaterials.DIAMOND ), USING_NETHERITE_TOOLS( - 500, ToolMaterials.NETHERITE + 504, ToolMaterials.NETHERITE ), EQUIP_GOLDEN_ARMOR( - 40, ArmorMaterials.GOLD + 44, ArmorMaterials.GOLD ), EQUIP_LEATHER_ARMOR( - 90, ArmorMaterials.LEATHER + 98, ArmorMaterials.LEATHER ), EQUIP_IRON_ARMOR( - 150, ArmorMaterials.IRON + 158, ArmorMaterials.IRON ), EQUIP_CHAINMAIL_ARMOR( - 200, ArmorMaterials.CHAIN + 203, ArmorMaterials.CHAIN ), EQUIP_DIAMOND_ARMOR( - 300, ArmorMaterials.DIAMOND + 305, ArmorMaterials.DIAMOND ), EQUIP_NETHERITE_ARMOR( - 550, ArmorMaterials.NETHERITE + 552, ArmorMaterials.NETHERITE ), NETHER( - 300, World.NETHER + 275, World.NETHER ), END( - 600, World.END + 575, World.END ), VILLAGER_MASON( diff --git a/src/main/java/com/diskree/achievetodo/advancements/AdvancementsTab.java b/src/main/java/com/diskree/achievetodo/advancements/AdvancementsTab.java index f74f6749..bc9374bf 100644 --- a/src/main/java/com/diskree/achievetodo/advancements/AdvancementsTab.java +++ b/src/main/java/com/diskree/achievetodo/advancements/AdvancementsTab.java @@ -57,30 +57,6 @@ public enum AdvancementsTab { EAT_MELON_SLICE, EAT_COOKIE ), - List.of( - EAT_MUSHROOM_STEW, - EAT_RABBIT_STEW, - EAT_HONEY_BOTTLE, - EAT_PUMPKIN_PIE, - EAT_GOLDEN_APPLE, - EAT_ENCHANTED_GOLDEN_APPLE, - EAT_BAKED_POTATO, - EAT_RABBIT, - EAT_MUTTON, - EAT_PORKCHOP - ), - List.of( - EAT_BEEF, - EAT_COOKED_SALMON, - EAT_COOKED_COD, - EAT_COOKED_RABBIT, - EAT_COOKED_CHICKEN, - EAT_COOKED_MUTTON, - EAT_COOKED_PORKCHOP, - EAT_COOKED_BEEF, - EAT_BREAD, - EAT_GOLDEN_CARROT - ), List.of( OPEN_CHEST, USING_CRAFTING_TABLE, @@ -92,14 +68,14 @@ public enum AdvancementsTab { OPEN_SMOKER ), List.of( - OPEN_BLAST_FURNACE, - USING_CARTOGRAPHY_TABLE, - OPEN_ENDER_CHEST, - OPEN_BREWING_STAND, - USING_SMITHING_TABLE, - USING_BEACON, - OPEN_SHULKER_BOX, - USING_ENCHANTING_TABLE + USING_GOLDEN_TOOLS, + EQUIP_GOLDEN_ARMOR, + USING_WOODEN_TOOLS, + USING_STONE_TOOLS, + EQUIP_LEATHER_ARMOR, + USING_IRON_TOOLS, + EQUIP_IRON_ARMOR, + EQUIP_CHAINMAIL_ARMOR ), List.of( JUMP, @@ -112,6 +88,21 @@ public enum AdvancementsTab { USING_WATER_BUCKET, USING_SHEARS ), + List.of( + VILLAGER_MASON, + VILLAGER_CARTOGRAPHER, + VILLAGER_LEATHERWORKER, + VILLAGER_SHEPHERD, + VILLAGER_BUTCHER, + VILLAGER_FARMER, + VILLAGER_CLERIC, + VILLAGER_FISHERMAN, + VILLAGER_FLETCHER, + VILLAGER_ARMORER, + VILLAGER_WEAPONSMITH, + VILLAGER_TOOLSMITH, + VILLAGER_LIBRARIAN + ), List.of( USING_CROSSBOW, BREAK_BLOCKS_IN_NEGATIVE_Y, @@ -124,18 +115,8 @@ public enum AdvancementsTab { FLY ), List.of( - USING_GOLDEN_TOOLS, - EQUIP_GOLDEN_ARMOR, - USING_WOODEN_TOOLS, - USING_STONE_TOOLS, - EQUIP_LEATHER_ARMOR, - USING_IRON_TOOLS, - EQUIP_IRON_ARMOR, - EQUIP_CHAINMAIL_ARMOR - ), - List.of( - EQUIP_DIAMOND_ARMOR, BlockedActionType.NETHER, + EQUIP_DIAMOND_ARMOR, USING_DIAMOND_TOOLS, USING_NETHERITE_TOOLS, EQUIP_NETHERITE_ARMOR, @@ -144,19 +125,38 @@ public enum AdvancementsTab { END_GATEWAY ), List.of( - VILLAGER_MASON, - VILLAGER_CARTOGRAPHER, - VILLAGER_LEATHERWORKER, - VILLAGER_SHEPHERD, - VILLAGER_BUTCHER, - VILLAGER_FARMER, - VILLAGER_CLERIC, - VILLAGER_FISHERMAN, - VILLAGER_FLETCHER, - VILLAGER_ARMORER, - VILLAGER_WEAPONSMITH, - VILLAGER_TOOLSMITH, - VILLAGER_LIBRARIAN + OPEN_BLAST_FURNACE, + USING_CARTOGRAPHY_TABLE, + OPEN_ENDER_CHEST, + OPEN_BREWING_STAND, + USING_SMITHING_TABLE, + USING_BEACON, + OPEN_SHULKER_BOX, + USING_ENCHANTING_TABLE + ), + List.of( + EAT_MUSHROOM_STEW, + EAT_RABBIT_STEW, + EAT_HONEY_BOTTLE, + EAT_PUMPKIN_PIE, + EAT_GOLDEN_APPLE, + EAT_ENCHANTED_GOLDEN_APPLE, + EAT_RABBIT, + EAT_MUTTON, + EAT_PORKCHOP, + EAT_BEEF + ), + List.of( + EAT_BAKED_POTATO, + EAT_COOKED_SALMON, + EAT_COOKED_COD, + EAT_COOKED_RABBIT, + EAT_COOKED_CHICKEN, + EAT_COOKED_MUTTON, + EAT_COOKED_PORKCHOP, + EAT_COOKED_BEEF, + EAT_BREAD, + EAT_GOLDEN_CARROT ) ) ), diff --git a/src/main/java/com/diskree/achievetodo/advancements/RandomAdvancements.java b/src/main/java/com/diskree/achievetodo/advancements/RandomAdvancements.java index b20163da..6b548cb8 100644 --- a/src/main/java/com/diskree/achievetodo/advancements/RandomAdvancements.java +++ b/src/main/java/com/diskree/achievetodo/advancements/RandomAdvancements.java @@ -955,10 +955,8 @@ private static PlacedAdvancement getAdvancement(ServerPlayerEntity player, boole return null; } PlayerAdvancementTracker playerAdvancementTracker = player.getAdvancementTracker(); - AdvancementManager advancementManager = playerAdvancementTracker.advancementManager; - Map progresses = playerAdvancementTracker.progress; ArrayList advancements = new ArrayList<>(); - for (AdvancementEntry advancementEntry : new ArrayList<>(progresses.keySet())) { + for (AdvancementEntry advancementEntry : new ArrayList<>(playerAdvancementTracker.visibleAdvancements)) { if (advancementEntry == null) { continue; } @@ -970,7 +968,7 @@ private static PlacedAdvancement getAdvancement(ServerPlayerEntity player, boole if (display == null || display.isHidden()) { continue; } - PlacedAdvancement placedAdvancement = advancementManager.get(advancementEntry); + PlacedAdvancement placedAdvancement = playerAdvancementTracker.advancementManager.get(advancementEntry); if (placedAdvancement == null) { continue; } @@ -1010,7 +1008,7 @@ private static PlacedAdvancement getAdvancement(ServerPlayerEntity player, boole continue; } } - AdvancementProgress progress = progresses.get(advancementEntry); + AdvancementProgress progress = playerAdvancementTracker.progress.get(advancementEntry); if (progress != null && progress.isDone()) { continue; } @@ -1019,6 +1017,6 @@ private static PlacedAdvancement getAdvancement(ServerPlayerEntity player, boole if (advancements.isEmpty()) { return null; } - return advancementManager.get(advancements.get(player.getRandom().nextInt(advancements.size()))); + return playerAdvancementTracker.advancementManager.get(advancements.get(player.getRandom().nextInt(advancements.size()))); } } diff --git a/src/main/java/com/diskree/achievetodo/datagen/AdvancementFunctionsGenerator.java b/src/main/java/com/diskree/achievetodo/datagen/AdvancementFunctionsGenerator.java new file mode 100644 index 00000000..b9a85f26 --- /dev/null +++ b/src/main/java/com/diskree/achievetodo/datagen/AdvancementFunctionsGenerator.java @@ -0,0 +1,24 @@ +package com.diskree.achievetodo.datagen; + +import com.diskree.achievetodo.action.BlockedActionType; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; + +import java.util.function.Consumer; + +// TODO Refactoring +public class AdvancementFunctionsGenerator extends FunctionProvider { + + protected AdvancementFunctionsGenerator(FabricDataOutput dataOutput) { + super(dataOutput); + } + + @Override + public void generateFunctions(Consumer consumer) { + for (BlockedActionType blockedAction : BlockedActionType.values()) { + String titleKey = "blocked." + blockedAction.getName() + ".title"; + String descriptionKey = "blocked." + blockedAction.getName() + ".description"; + String command = "tellraw @a {\"translate\":\"%1$s has unblocked %2$s%3$s%4$s\",\"with\":[{\"selector\":\"@s\"},{\"color\":\"yellow\",\"text\":\"[\"},{\"color\":\"yellow\",\"translate\":\"" + titleKey + "\",\"hoverEvent\":{\"action\":\"show_text\",\"contents\":{\"color\":\"yellow\",\"translate\":\"" + titleKey + "\",\"extra\":[{\"text\":\"\\n\"},{\"color\":\"yellow\",\"translate\":\"" + descriptionKey + "\"},{\"text\":\"\\n\\n\"},{\"color\":\"gray\",\"italic\":true,\"translate\":\"%1$s tab\",\"with\":[{\"translate\":\"advancement.root.blocked_actions.title\"}]}]}}},{\"color\":\"yellow\",\"text\":\"]\"}]}"; + consumer.accept(new Function(blockedAction.getName(), command)); + } + } +} diff --git a/src/main/java/com/diskree/achievetodo/datagen/AdvancementsGenerator.java b/src/main/java/com/diskree/achievetodo/datagen/AdvancementsGenerator.java index 548e98af..f7283c47 100644 --- a/src/main/java/com/diskree/achievetodo/datagen/AdvancementsGenerator.java +++ b/src/main/java/com/diskree/achievetodo/datagen/AdvancementsGenerator.java @@ -8,17 +8,18 @@ import net.minecraft.advancement.Advancement; import net.minecraft.advancement.AdvancementEntry; import net.minecraft.advancement.AdvancementFrame; +import net.minecraft.advancement.AdvancementRewards; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.advancement.criterion.ImpossibleCriterion; import net.minecraft.advancement.criterion.TickCriterion; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.function.Consumer; +// TODO Refactoring public class AdvancementsGenerator extends FabricAdvancementProvider { public static final String BLOCKED_ACTION_DEMYSTIFIED_CRITERION_PREFIX = "demystified_"; @@ -30,6 +31,14 @@ protected AdvancementsGenerator(FabricDataOutput output) { @Override public void generateAdvancement(Consumer consumer) { + Map countMap = new HashMap<>(); + for (BlockedActionType actionToCheck : BlockedActionType.values()) { + BlockedActionType action = countMap.get(actionToCheck.getUnblockAdvancementsCount()); + if (action != null) { + throw new IllegalArgumentException("Same count of required advancements in " + action.getName() + " and " + actionToCheck.getName()); + } + countMap.put(actionToCheck.getUnblockAdvancementsCount(), actionToCheck); + } for (AdvancementsTab root : AdvancementsTab.values()) { if (!root.isModded || root == AdvancementsTab.HINTS) { continue; @@ -98,6 +107,7 @@ public void generateAdvancement(Consumer consumer) { private Advancement.Builder setupRequirements(Advancement.Builder builder, IGeneratedAdvancement advancement) { if (advancement instanceof BlockedActionType blockedAction) { + builder.rewards(AdvancementRewards.Builder.function(new Identifier("achievetodo_blocked_actions/" + blockedAction.getName()))); builder.criterion(BLOCKED_ACTION_DEMYSTIFIED_CRITERION_PREFIX + blockedAction.getName(), Criteria.IMPOSSIBLE.create(new ImpossibleCriterion.Conditions())); builder.criterion(BLOCKED_ACTION_UNBLOCKED_CRITERION_NAME, Criteria.IMPOSSIBLE.create(new ImpossibleCriterion.Conditions())); } diff --git a/src/main/java/com/diskree/achievetodo/datagen/DataGeneratorEntrypoint.java b/src/main/java/com/diskree/achievetodo/datagen/DataGeneratorEntrypoint.java index b356db51..3504949d 100644 --- a/src/main/java/com/diskree/achievetodo/datagen/DataGeneratorEntrypoint.java +++ b/src/main/java/com/diskree/achievetodo/datagen/DataGeneratorEntrypoint.java @@ -8,5 +8,6 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen. public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); pack.addProvider(AdvancementsGenerator::new); + pack.addProvider(AdvancementFunctionsGenerator::new); } } diff --git a/src/main/java/com/diskree/achievetodo/datagen/Function.java b/src/main/java/com/diskree/achievetodo/datagen/Function.java new file mode 100644 index 00000000..685c44ec --- /dev/null +++ b/src/main/java/com/diskree/achievetodo/datagen/Function.java @@ -0,0 +1,4 @@ +package com.diskree.achievetodo.datagen; + +public record Function(String name, String command) { +} \ No newline at end of file diff --git a/src/main/java/com/diskree/achievetodo/datagen/FunctionProvider.java b/src/main/java/com/diskree/achievetodo/datagen/FunctionProvider.java new file mode 100644 index 00000000..e17c6718 --- /dev/null +++ b/src/main/java/com/diskree/achievetodo/datagen/FunctionProvider.java @@ -0,0 +1,63 @@ +package com.diskree.achievetodo.datagen; + +import com.google.common.collect.Sets; +import com.google.common.hash.Hashing; +import com.google.common.hash.HashingOutputStream; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.minecraft.data.DataOutput; +import net.minecraft.data.DataProvider; +import net.minecraft.data.DataWriter; +import net.minecraft.util.Identifier; +import net.minecraft.util.Util; + +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; + +public abstract class FunctionProvider implements DataProvider { + + protected final FabricDataOutput dataOutput; + + protected FunctionProvider(FabricDataOutput dataOutput) { + this.dataOutput = dataOutput; + } + + public abstract void generateFunctions(Consumer consumer); + + @SuppressWarnings({"UnstableApiUsage", "deprecation"}) + @Override + public CompletableFuture run(DataWriter writer) { + return CompletableFuture.runAsync(() -> { + final Set functions = Sets.newHashSet(); + generateFunctions(functions::add); + try { + for (Function function : functions) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + HashingOutputStream hashingOutputStream = new HashingOutputStream(Hashing.sha1(), byteArrayOutputStream); + try (BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(hashingOutputStream, StandardCharsets.UTF_8))) { + bufferedWriter.write(function.command()); + } + writer.write(getFunctionPath(function.name()), byteArrayOutputStream.toByteArray(), hashingOutputStream.hash()); + } + } catch (IOException ignored) { + } + }, Util.getMainWorkerExecutor()); + } + + private Path getFunctionPath(String name) { + return dataOutput + .getResolver(DataOutput.OutputType.DATA_PACK, "functions") + .resolve(new Identifier("achievetodo_blocked_actions/" + name), "mcfunction"); + } + + @Override + public String getName() { + return "Functions"; + } +} diff --git a/src/main/resources/assets/achievetodo/lang/en_us.json b/src/main/resources/assets/achievetodo/lang/en_us.json index ebaba7f3..1e9bbbc3 100644 --- a/src/main/resources/assets/achievetodo/lang/en_us.json +++ b/src/main/resources/assets/achievetodo/lang/en_us.json @@ -58,7 +58,7 @@ "blocked.using_cartography_table": "You cannot use a cartography table yet", "blocked.using_smithing_table": "You cannot use a smithing table yet", - "unblock.amount": ". Advancements left until unlocking: ", + "unblock.amount": ". Advancements left: ", "unblock.food": "Food available", "unblock.action": "Action available", "unblock.item": "Item available", @@ -342,6 +342,8 @@ "hints.no_new_updates.title": "No New Updates", "hints.no_new_updates.description": "Try to get hint if there are no advancements that have hints", + "%1$s has unblocked %2$s%3$s%4$s": "%1$s has unblocked %2$s%3$s%4$s", + "error.screen.title": "Oops!", "external.pack.open_page": "Open Page", diff --git a/src/main/resources/assets/achievetodo/lang/ru_ru.json b/src/main/resources/assets/achievetodo/lang/ru_ru.json index ba0cbe55..91abb1b5 100644 --- a/src/main/resources/assets/achievetodo/lang/ru_ru.json +++ b/src/main/resources/assets/achievetodo/lang/ru_ru.json @@ -55,7 +55,7 @@ "blocked.using_cartography_table": "Вы сейчас не можете использовать стол картографа", "blocked.using_smithing_table": "Вы сейчас не можете использовать стол кузнеца", - "unblock.amount": ". Для разблокировки осталось выполнить достижений: ", + "unblock.amount": ". Осталось выполнить достижений: ", "unblock.food": "Доступна еда", "unblock.action": "Доступно действие", "unblock.item": "Доступен предмет", @@ -339,6 +339,8 @@ "hints.no_new_updates.title": "Новых обновлений нет", "hints.no_new_updates.description": "Попытайтесь получить подсказку при отсутствии достижений, по которым есть что подсказать", + "%1$s has unblocked %2$s%3$s%4$s": "%1$s разблокировал %2$s%3$s%4$s", + "error.screen.title": "Упс!", "external.pack.open_page": "Открыть страницу", diff --git a/src/main/resources/resourcepacks/bacap_better_ru/assets/minecraft/lang/ru_ru.json b/src/main/resources/resourcepacks/bacap_better_ru/assets/minecraft/lang/ru_ru.json index 8173813f..2b3678a5 100644 --- a/src/main/resources/resourcepacks/bacap_better_ru/assets/minecraft/lang/ru_ru.json +++ b/src/main/resources/resourcepacks/bacap_better_ru/assets/minecraft/lang/ru_ru.json @@ -4149,7 +4149,7 @@ "Get hunted by a Polar Bear": "Пусть вас изобьёт белый медведь", "Dive Bomb": "Пушечное ядро!", -"Dive into water from a cliff at least 50 blocks tall": "Нырните в воду со скалы, высотой не менее 50 блоков", +"Dive into water from a cliff at least 50 blocks tall": "Нырните в воду со скалы, высотой не менее 50 блоков. [работает нестабильно (MC-253212)]", "Captain America": "Капитан Америка", "Get completely frozen inside two blocks of Powder Snow for a loooong time.": "Полностью замёрзните в двух блоках рыхлого снега на дооолгое время",