diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/Ygasi.java | 9 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java | 88 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java | 4 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java | 36 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java | 12 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java | 4 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/AdvancementProvider.java | 1 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/Advancements.java | 207 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/util/GetAdvancementProgress.java | 10 | ||||
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/util/YgasiUtils.java (renamed from src/main/java/dev/mayaqq/ygasi/util/GrantAdvancementCriterion.java) | 8 |
10 files changed, 274 insertions, 105 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/Ygasi.java b/src/main/java/dev/mayaqq/ygasi/Ygasi.java index 4d13d53..5c598ee 100644 --- a/src/main/java/dev/mayaqq/ygasi/Ygasi.java +++ b/src/main/java/dev/mayaqq/ygasi/Ygasi.java @@ -4,8 +4,9 @@ import dev.mayaqq.ygasi.items.SkillBookItem; import dev.mayaqq.ygasi.registry.CommandRegistry; import dev.mayaqq.ygasi.registry.ConfigRegistry; import dev.mayaqq.ygasi.registry.StatRegistry; -import dev.mayaqq.ygasi.util.GrantAdvancementCriterion; +import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.polymer.api.item.PolymerItemGroup; +import eu.pb4.polymer.api.item.PolymerItemUtils; import eu.pb4.polymer.api.resourcepack.PolymerModelData; import eu.pb4.polymer.api.resourcepack.PolymerRPUtils; import net.fabricmc.api.ModInitializer; @@ -41,10 +42,10 @@ public class Ygasi implements ModInitializer { if (ConfigRegistry.CONFIG.enableSkillBook) { ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { - if (!handler.player.getScoreboardTags().contains("ygasi:skill_book_unlocked")) { - handler.player.addScoreboardTag("ygasi:skill_book_unlocked"); + if (!handler.player.getScoreboardTags().contains("skill_book_unlocked")) { + handler.player.addScoreboardTag("skill_book_unlocked"); handler.player.getInventory().offerOrDrop(new ItemStack(SKILL_BOOK)); - GrantAdvancementCriterion.grantAdvancementCriterion(handler.player, new Identifier("ygasi", "skill_book"), "opened_skill_menu"); + YgasiUtils.grantAdvancementCriterion(handler.player, new Identifier("ygasi", "recipes/minecraft_ygasi/skill_book"), "opened_skill_menu"); } }); } diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java index ca02eec..a9ccb71 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java @@ -1,7 +1,6 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.util.GetAdvancementProgress; -import dev.mayaqq.ygasi.util.GrantAdvancementCriterion; +import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.*; import net.minecraft.item.ItemStack; @@ -50,9 +49,9 @@ public class BranchGui { } //branch items - if (!GetAdvancementProgress.get(player, "mercenary")) { + if (!YgasiUtils.getAdvancementProgress(player, "mercenary")) { gui.setSlot(11, new GuiElementBuilder() - .setItem(Items.IRON_SWORD) + .setItem(Items.DIAMOND_SWORD) .setCustomModelData(1) .hideFlag(ItemStack.TooltipSection.MODIFIERS) .addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY))) @@ -62,7 +61,7 @@ public class BranchGui { ); } else { gui.setSlot(11, new GuiElementBuilder() - .setItem(Items.IRON_SWORD) + .setItem(Items.DIAMOND_SWORD) .hideFlag(ItemStack.TooltipSection.MODIFIERS) .glow() .setName(Text.literal("Mercenary") @@ -71,7 +70,7 @@ public class BranchGui { ); } - if (!GetAdvancementProgress.get(player, "wizardry")) { + if (!YgasiUtils.getAdvancementProgress(player, "wizardry")) { gui.setSlot(13, new GuiElementBuilder() .setItem(Items.BLAZE_ROD) .addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY))) @@ -89,7 +88,7 @@ public class BranchGui { ); } - if (!GetAdvancementProgress.get(player, "druidry")) { + if (!YgasiUtils.getAdvancementProgress(player, "druidry")) { gui.setSlot(15, new GuiElementBuilder() .setItem(Items.OAK_SAPLING) .addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY))) @@ -106,7 +105,33 @@ public class BranchGui { .setCallback((index, clickType, actionType) -> DruidryGui.gui(player)) ); } - GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu"); + + if (!YgasiUtils.getAdvancementProgress(player, "extra")) { + gui.setSlot(26, new GuiElementBuilder() + .setItem(Items.BOOK) + .addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost / 2).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY))) + .setName(Text.literal("Extra") + .setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.BLUE))) + .setCallback((index, clickType, actionType) -> save(player, "extra", "§9Extra Skills")) + ); + } else { + gui.setSlot(26, new GuiElementBuilder() + .setItem(Items.BOOK) + .glow() + .setName(Text.literal("Extra Skills") + .setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.BLUE))) + .setCallback((index, clickType, actionType) -> ExtraGui.gui(player)) + ); + } + + //info item + gui.setSlot(18, new GuiElementBuilder() + .setItem(Items.PAPER) + .setName(Text.literal("Info").formatted(Formatting.GOLD).formatted(Formatting.BOLD)) + .setCallback((index, clickType, actionType) -> infoMessage(player)) + ); + + YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu"); gui.open(); } catch (Exception e) { @@ -114,24 +139,39 @@ public class BranchGui { } } public static void save(ServerPlayerEntity player, String branch, String branchName) { - if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost) { - player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost); - player.sendMessage(Text.of("You have selected the §a" + branchName + " §fbranch!"), false); - player.closeHandledScreen(); - if (branch.equals("mercenary")) { - GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/mercenary"), "unlocked_mercenary"); - MercenaryGui.gui(player); - } else if (branch.equals("wizardry")) { - GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/wizardry"), "unlocked_wizardry"); - WizardryGui.gui(player); - } else if (branch.equals("druidry")) { - GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/druidry"), "unlocked_druidry"); - DruidryGui.gui(player); + if (branch.equals("extra")) { + if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost / 2) { + player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost / 2); + YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/extra"), "unlocked_extra"); + player.sendMessage(Text.of("§aYou have unlocked the " + branchName + " branch!"), false); + ExtraGui.gui(player); + } else { + player.sendMessage(Text.of("§cYou do not have enough skill points to unlock this branch!"), false); } - } else { - player.sendMessage(Text.translatable("gui.ygasi.no.skill").setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.RED)), false); - player.closeHandledScreen(); + if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost) { + player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost); + player.sendMessage(Text.of("You have selected the §a" + branchName + " §fbranch!"), false); + player.closeHandledScreen(); + if (branch.equals("mercenary")) { + YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/mercenary"), "unlocked_mercenary"); + MercenaryGui.gui(player); + } else if (branch.equals("wizardry")) { + YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/wizardry"), "unlocked_wizardry"); + WizardryGui.gui(player); + } else if (branch.equals("druidry")) { + YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/druidry"), "unlocked_druidry"); + DruidryGui.gui(player); + } + + } else { + player.sendMessage(Text.translatable("gui.ygasi.no.skill").setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.RED)), false); + player.closeHandledScreen(); + } } } + public static void infoMessage(ServerPlayerEntity player) { + player.closeHandledScreen(); + player.sendMessage(Text.translatable("gui.ygasi.info.main"), false); + } }
\ No newline at end of file diff --git a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java index d2be67e..dc5e5e7 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java @@ -1,6 +1,6 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.util.GetAdvancementProgress; +import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerType; @@ -13,7 +13,7 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class DruidryGui { public static void gui(ServerPlayerEntity player) { try { - if (!GetAdvancementProgress.get(player, "druidry")) { + if (!YgasiUtils.getAdvancementProgress(player, "druidry")) { player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); BranchGui.gui(player); } else { diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java new file mode 100644 index 0000000..98ca697 --- /dev/null +++ b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java @@ -0,0 +1,36 @@ +package dev.mayaqq.ygasi.gui; + +import dev.mayaqq.ygasi.util.YgasiUtils; +import eu.pb4.sgui.api.elements.GuiElementBuilder; +import net.minecraft.item.Items; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.stat.Stats; +import net.minecraft.text.Text; + +import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; + +public class ExtraGui { + public static void gui(ServerPlayerEntity player) { + try { + if (!YgasiUtils.getAdvancementProgress(player, "extra")) { + player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); + BranchGui.gui(player); + } else { + SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X3, player, false) {}; + + gui.setTitle(Text.of( "§9§lExtra " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))); + + for (int x = 0; x <= 26; x++) { + gui.setSlot(x, new GuiElementBuilder() + .setItem(Items.GRAY_STAINED_GLASS_PANE) + .setName(Text.of(" ")) + ); + } + gui.open(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +}
\ No newline at end of file diff --git a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java index ea75c43..79cc08d 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java @@ -1,6 +1,6 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.util.GetAdvancementProgress; +import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerType; @@ -13,14 +13,14 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class MercenaryGui { public static void gui(ServerPlayerEntity player) { try { - if (!GetAdvancementProgress.get(player, "mercenary")) { + if (!YgasiUtils.getAdvancementProgress(player, "mercenary")) { player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); BranchGui.gui(player); } else { SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X6, player, false) {}; gui.setTitle(Text.of( "§c§lMercenary " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))); - + //background items for (int x = 0; x <= 53; x++) { gui.setSlot(x, new GuiElementBuilder() .setItem(Items.GRAY_STAINED_GLASS_PANE) @@ -28,6 +28,12 @@ public class MercenaryGui { ); } + //skill items + gui.setSlot(49, new GuiElementBuilder() + .setItem(Items.DIAMOND_BLOCK) + .setName(Text.of("§c§lMercenary Unlocked!")) + .addLoreLine(Text.of("§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))) + ); gui.open(); } diff --git a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java index f5ae47f..d049e5a 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java @@ -1,6 +1,6 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.util.GetAdvancementProgress; +import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerType; @@ -13,7 +13,7 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class WizardryGui { public static void gui(ServerPlayerEntity player) { try { - if (!GetAdvancementProgress.get(player, "wizardry")) { + if (!YgasiUtils.getAdvancementProgress(player, "wizardry")) { player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); BranchGui.gui(player); } else { diff --git a/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/AdvancementProvider.java b/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/AdvancementProvider.java index 6a91296..5748316 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/AdvancementProvider.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/AdvancementProvider.java @@ -1,6 +1,5 @@ package dev.mayaqq.ygasi.registry.dataGen.advancements; -import dev.mayaqq.ygasi.registry.dataGen.advancements.Advancements; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider; import net.minecraft.advancement.Advancement; diff --git a/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/Advancements.java b/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/Advancements.java index 6cd5665..130a885 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/Advancements.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/dataGen/advancements/Advancements.java @@ -16,66 +16,159 @@ public class Advancements implements Consumer<Consumer<Advancement>> { @Override public void accept(Consumer<Advancement> consumer) { - Advancement rootAdvancement = Advancement.Builder.create() - .display( - Items.DIAMOND, // The display icon - Text.literal("You've got a skill issue!"), // The title - Text.literal("The journey begins here!"), // The description - new Identifier("textures/block/sculk_catalyst_top.png"), // Background image used - AdvancementFrame.CHALLENGE, // Options: TASK, CHALLENGE, GOAL - true, // Show toast top right - false, // Announce to chat - false // Hidden in the advancement tab - ) - // The first string used in criterion is the name referenced by other advancements when they want to have 'requirements' - .criterion("opened_skill_menu", new ImpossibleCriterion.Conditions()) - .rewards(AdvancementRewards.Builder.experience(1)) - .build(consumer, "ygasi" + "/root"); + //main root advancement + Advancement rootAdvancement = Advancement.Builder.create().display(Items.DIAMOND, // The display icon + Text.translatable("advancements.ygasi.root.title"), // The title + Text.translatable("advancements.ygasi.root.description"), // The description + new Identifier("textures/block/sculk_catalyst_top.png"), // Background image used + AdvancementFrame.CHALLENGE, // Options: TASK, CHALLENGE, GOAL + true, // Show toast top right + false, // Announce to chat + false // Hidden in the advancement tab + ).criterion("opened_skill_menu", new ImpossibleCriterion.Conditions()).rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/root"); + //branch advancements Advancement mercenary = Advancement.Builder.create().parent(rootAdvancement) - .display( - Items.IRON_SWORD, - Text.literal("Mercenary"), - Text.literal("Unlock the mercenary branch!"), - null, - AdvancementFrame.GOAL, - false, - false, - false - ) - .criterion("unlocked_mercenary", new ImpossibleCriterion.Conditions()) - .criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) - .rewards(AdvancementRewards.Builder.experience(1)) - .build(consumer, "ygasi" + "/mercenary"); + .display(Items.DIAMOND_SWORD, Text.translatable("advancements.ygasi.mercenary.title"), Text.translatable("advancements.ygasi.mercenary.description"), null, AdvancementFrame.GOAL, false, false, false) + .criterion("unlocked_mercenary", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/mercenary"); Advancement wizardry = Advancement.Builder.create().parent(rootAdvancement) - .display( - Items.BLAZE_ROD, - Text.literal("Wizardry"), - Text.literal("Unlock the wizardry branch!"), - null, - AdvancementFrame.GOAL, - false, - false, - false - ) - .criterion("unlocked_wizardry", new ImpossibleCriterion.Conditions()) - .criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) - .rewards(AdvancementRewards.Builder.experience(1)) - .build(consumer, "ygasi" + "/wizardry"); + .display(Items.BLAZE_ROD, Text.translatable("advancements.ygasi.wizardry.title"), Text.translatable("advancements.ygasi.wizardry.description"), null, AdvancementFrame.GOAL, false, false, false) + .criterion("unlocked_wizardry", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/wizardry"); Advancement druidry = Advancement.Builder.create().parent(rootAdvancement) - .display( - Items.OAK_SAPLING, - Text.literal("Druidry"), - Text.literal("Unlock the druidry branch!"), - null, - AdvancementFrame.GOAL, - false, - false, - false - ) - .criterion("unlocked_druidry", new ImpossibleCriterion.Conditions()) - .criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) - .rewards(AdvancementRewards.Builder.experience(1)) - .build(consumer, "ygasi" + "/druidry"); + .display(Items.OAK_SAPLING, Text.translatable("advancements.ygasi.druidry.title"), Text.translatable("advancements.ygasi.druidry.description"), null, AdvancementFrame.GOAL, false, false, false) + .criterion("unlocked_druidry", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/druidry"); + Advancement extra = Advancement.Builder.create().parent(rootAdvancement) + .display(Items.EMERALD, Text.translatable("advancements.ygasi.extra.title"), Text.translatable("advancements.ygasi.extra.description"), null, AdvancementFrame.GOAL, false, false, false) + .criterion("unlocked_extra", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, rootAdvancement.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/extra"); + + //mercenary skills + + Advancement offence1 = Advancement.Builder.create().parent(mercenary) + .display(Items.IRON_SWORD, Text.translatable("advancements.ygasi.mercenary.offence1.title"), Text.translatable("advancements.ygasi.mercenary.offence1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_offence1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, mercenary.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/offence1"); + Advancement offence2 = Advancement.Builder.create().parent(offence1) + .display(Items.IRON_SWORD, Text.translatable("advancements.ygasi.mercenary.offence2.title"), Text.translatable("advancements.ygasi.mercenary.offence2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_offence2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, offence1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/offence2"); + Advancement offence3 = Advancement.Builder.create().parent(offence2) + .display(Items.IRON_SWORD, Text.translatable("advancements.ygasi.mercenary.offence3.title"), Text.translatable("advancements.ygasi.mercenary.offence3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_offence3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, offence2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/offence3"); + + Advancement ninja1 = Advancement.Builder.create().parent(mercenary) + .display(Items.BAMBOO, Text.translatable("advancements.ygasi.mercenary.ninja1.title"), Text.translatable("advancements.ygasi.mercenary.ninja1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_ninja1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, mercenary.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/ninja1"); + Advancement ninja2 = Advancement.Builder.create().parent(ninja1) + .display(Items.BAMBOO, Text.translatable("advancements.ygasi.mercenary.ninja2.title"), Text.translatable("advancements.ygasi.mercenary.ninja2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_ninja2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, ninja1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/ninja2"); + Advancement ninja3 = Advancement.Builder.create().parent(ninja2) + .display(Items.BAMBOO, Text.translatable("advancements.ygasi.mercenary.ninja3.title"), Text.translatable("advancements.ygasi.mercenary.ninja3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_ninja3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, ninja2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/ninja3"); + + Advancement defence1 = Advancement.Builder.create().parent(mercenary) + .display(Items.IRON_CHESTPLATE, Text.translatable("advancements.ygasi.mercenary.defence1.title"), Text.translatable("advancements.ygasi.mercenary.defence1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_defence1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, mercenary.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/defence1"); + Advancement defence2 = Advancement.Builder.create().parent(defence1) + .display(Items.IRON_CHESTPLATE, Text.translatable("advancements.ygasi.mercenary.defence2.title"), Text.translatable("advancements.ygasi.mercenary.defence2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_defence2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, defence1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/defence2"); + Advancement defence3 = Advancement.Builder.create().parent(defence2) + .display(Items.IRON_CHESTPLATE, Text.translatable("advancements.ygasi.mercenary.defence3.title"), Text.translatable("advancements.ygasi.mercenary.defence3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_defence3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, defence2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/defence3"); + + //wizardry skills + + Advancement fight1 = Advancement.Builder.create().parent(wizardry) + .display(Items.BLAZE_POWDER, Text.translatable("advancements.ygasi.wizardry.fight1.title"), Text.translatable("advancements.ygasi.wizardry.fight1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_fight1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, wizardry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/fight1"); + Advancement fight2 = Advancement.Builder.create().parent(fight1) + .display(Items.BLAZE_POWDER, Text.translatable("advancements.ygasi.wizardry.fight2.title"), Text.translatable("advancements.ygasi.wizardry.fight2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_fight2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, fight1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/fight2"); + Advancement fight3 = Advancement.Builder.create().parent(fight2) + .display(Items.BLAZE_POWDER, Text.translatable("advancements.ygasi.wizardry.fight3.title"), Text.translatable("advancements.ygasi.wizardry.fight3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_fight3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, fight2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/fight3"); + + Advancement element1 = Advancement.Builder.create().parent(wizardry) + .display(Items.FIRE_CHARGE, Text.translatable("advancements.ygasi.wizardry.element1.title"), Text.translatable("advancements.ygasi.wizardry.element1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_element1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, wizardry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/element1"); + Advancement element2 = Advancement.Builder.create().parent(element1) + .display(Items.FIRE_CHARGE, Text.translatable("advancements.ygasi.wizardry.element2.title"), Text.translatable("advancements.ygasi.wizardry.element2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_element2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, element1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/element2"); + Advancement element3 = Advancement.Builder.create().parent(element2) + .display(Items.FIRE_CHARGE, Text.translatable("advancements.ygasi.wizardry.element3.title"), Text.translatable("advancements.ygasi.wizardry.element3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_element3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, element2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/element3"); + + Advancement force1 = Advancement.Builder.create().parent(wizardry) + .display(Items.ENDER_PEARL, Text.translatable("advancements.ygasi.wizardry.force1.title"), Text.translatable("advancements.ygasi.wizardry.force1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_force1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, wizardry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/force1"); + Advancement force2 = Advancement.Builder.create().parent(force1) + .display(Items.ENDER_PEARL, Text.translatable("advancements.ygasi.wizardry.force2.title"), Text.translatable("advancements.ygasi.wizardry.force2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_force2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, force1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/force2"); + Advancement force3 = Advancement.Builder.create().parent(force2) + .display(Items.ENDER_PEARL, Text.translatable("advancements.ygasi.wizardry.force3.title"), Text.translatable("advancements.ygasi.wizardry.force3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_force3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, force2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/force3"); + + //druidry skills + + Advancement necromancy1 = Advancement.Builder.create().parent(druidry) + .display(Items.BONE, Text.translatable("advancements.ygasi.druidry.necromancy1.title"), Text.translatable("advancements.ygasi.druidry.necromancy1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_necromancy1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, druidry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/necromancy1"); + Advancement necromancy2 = Advancement.Builder.create().parent(necromancy1) + .display(Items.BONE, Text.translatable("advancements.ygasi.druidry.necromancy2.title"), Text.translatable("advancements.ygasi.druidry.necromancy2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_necromancy2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, necromancy1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/necromancy2"); + Advancement necromancy3 = Advancement.Builder.create().parent(necromancy2) + .display(Items.BONE, Text.translatable("advancements.ygasi.druidry.necromancy3.title"), Text.translatable("advancements.ygasi.druidry.necromancy3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_necromancy3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, necromancy2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/necromancy3"); + + Advancement nature1 = Advancement.Builder.create().parent(druidry) + .display(Items.GRASS_BLOCK, Text.translatable("advancements.ygasi.druidry.nature1.title"), Text.translatable("advancements.ygasi.druidry.nature1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_nature1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, druidry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/nature1"); + Advancement nature2 = Advancement.Builder.create().parent(nature1) + .display(Items.GRASS_BLOCK, Text.translatable("advancements.ygasi.druidry.nature2.title"), Text.translatable("advancements.ygasi.druidry.nature2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_nature2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, nature1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/nature2"); + Advancement nature3 = Advancement.Builder.create().parent(nature2) + .display(Items.GRASS_BLOCK, Text.translatable("advancements.ygasi.druidry.nature3.title"), Text.translatable("advancements.ygasi.druidry.nature3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_nature3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, nature2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/nature3"); + + Advancement protean1 = Advancement.Builder.create().parent(druidry) + .display(Items.SLIME_BALL, Text.translatable("advancements.ygasi.druidry.protean1.title"), Text.translatable("advancements.ygasi.druidry.protean1.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_protean1", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, druidry.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/protean1"); + Advancement protean2 = Advancement.Builder.create().parent(protean1) + .display(Items.SLIME_BALL, Text.translatable("advancements.ygasi.druidry.protean2.title"), Text.translatable("advancements.ygasi.druidry.protean2.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_protean2", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, protean1.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/protean2"); + Advancement protean3 = Advancement.Builder.create().parent(protean2) + .display(Items.SLIME_BALL, Text.translatable("advancements.ygasi.druidry.protean3.title"), Text.translatable("advancements.ygasi.druidry.protean3.description"), null, AdvancementFrame.TASK, false, false, true) + .criterion("unlocked_protean3", new ImpossibleCriterion.Conditions()).criterion("gotten_previous", new AdvancementGottenCriterion.Conditions(EntityPredicate.Extended.EMPTY, protean2.getId())) + .rewards(AdvancementRewards.Builder.experience(1)).build(consumer, "ygasi" + "/protean3"); + + //extra + } }
\ No newline at end of file diff --git a/src/main/java/dev/mayaqq/ygasi/util/GetAdvancementProgress.java b/src/main/java/dev/mayaqq/ygasi/util/GetAdvancementProgress.java deleted file mode 100644 index 9b4d4a8..0000000 --- a/src/main/java/dev/mayaqq/ygasi/util/GetAdvancementProgress.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.mayaqq.ygasi.util; - -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; - -public class GetAdvancementProgress { - public static boolean get(ServerPlayerEntity player, String advancement) { - return player.getAdvancementTracker().getProgress(player.getServer().getAdvancementLoader().get(new Identifier("minecraft", "ygasi/" + advancement))).isDone(); - } -} diff --git a/src/main/java/dev/mayaqq/ygasi/util/GrantAdvancementCriterion.java b/src/main/java/dev/mayaqq/ygasi/util/YgasiUtils.java index c141c06..ba3cfc8 100644 --- a/src/main/java/dev/mayaqq/ygasi/util/GrantAdvancementCriterion.java +++ b/src/main/java/dev/mayaqq/ygasi/util/YgasiUtils.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; import static dev.mayaqq.ygasi.Ygasi.LOGGER; -public class GrantAdvancementCriterion { +public class YgasiUtils { public static void grantAdvancementCriterion(@NotNull ServerPlayerEntity serverPlayerEntity, Identifier advancementIdentifier, String criterion) { if (serverPlayerEntity.getServer() == null) { return; @@ -26,4 +26,8 @@ public class GrantAdvancementCriterion { } } } -} + + public static boolean getAdvancementProgress(ServerPlayerEntity player, String advancement) { + return player.getAdvancementTracker().getProgress(player.getServer().getAdvancementLoader().get(new Identifier("minecraft", "ygasi/" + advancement))).isDone(); + } +}
\ No newline at end of file |