aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/registry
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2022-12-23 22:31:38 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2022-12-23 22:31:38 +0100
commitf7ca47ba8132addd94928aa8615448c47a6b3d7b (patch)
treea46151060500ffba77630e64817a4bfb842268e0 /src/main/java/dev/mayaqq/ygasi/registry
parente5bc4dae41d2d3e04440a4fe02793d4084427437 (diff)
downloadygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.tar.gz
ygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.tar.bz2
ygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.zip
Enormous amounts of trolling :tomfoolery:, not only that I fixed basically everything and switched the entire system to advancements, it now also has a cool custom book that you can open and stuff! Only issue I'm currently facing is that you get a skill point when you get the advancement for opening the gui and clicking stuff... right not that big of an issue but when I add 2 billion advancements its gonna hurt a bit. Love, Mayaqq
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/registry')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/AdvancementRegistry.java4
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java5
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java2
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java78
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/advancements/Advancements.java76
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/AdvancementProvider.java18
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/DataGenRegistry.java (renamed from src/main/java/dev/mayaqq/ygasi/registry/DataGenRegistry.java)4
7 files changed, 99 insertions, 88 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/AdvancementRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/AdvancementRegistry.java
deleted file mode 100644
index 09aa2c5..0000000
--- a/src/main/java/dev/mayaqq/ygasi/registry/AdvancementRegistry.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package dev.mayaqq.ygasi.registry;
-
-public class AdvancementRegistry {
-}
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
index 62d8dea..1da9830 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
@@ -57,10 +57,7 @@ public class CommandRegistry {
.executes(context -> {
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target");
player.resetStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS));
- File playerData = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + player.getUuid() + ".json");
- playerData.delete();
- PlayerDataRegistry.load(player.getUuid());
- context.getSource().sendMessage(Text.literal("§aSkill Points reset to 0 and all skill data deleted for " + player.getEntityName() + "."));
+ context.getSource().sendMessage(Text.literal("§aSkill Points reset to 0 for " + player.getEntityName() + "."));
return 1;
})))
.then(literal("add")
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
index f6e0c82..658f044 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
@@ -50,6 +50,8 @@ public class ConfigRegistry {
//the thing to write in the config file
public int pointsRewarded = 1;
public int branchCost = 16;
+ public Boolean enableSkillBook = true;
+
public Config() {}
}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java
deleted file mode 100644
index d3fd387..0000000
--- a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package dev.mayaqq.ygasi.registry;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.SerializedName;
-import net.fabricmc.loader.api.FabricLoader;
-
-import java.io.*;
-import java.util.*;
-
-public class PlayerDataRegistry {
- public static PlayerData PLAYERDATA = new PlayerData();
- public static EmptyPlayerData EMPTYPLAYERDATA = new EmptyPlayerData();
- private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
-
-
- public static void load(UUID uuid) {
- //this isnt working :sob:
- File playerDataFolder = new File(FabricLoader.getInstance().getGameDir().toFile(), "ygasi");
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- if (!playerDataFolder.exists()) {
- playerDataFolder.mkdir();
- }
- if (!playerDatFile.exists()) {
- try {
- playerDatFile.createNewFile();
- saveEmpty(uuid);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } else {
- try {
- PLAYERDATA = gson.fromJson(new FileReader(playerDatFile), PlayerData.class);
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static void save(UUID uuid) {
- try {
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- var writer = new FileWriter(playerDatFile);
- writer.write(gson.toJson(PLAYERDATA));
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public static void saveEmpty(UUID uuid) {
- try {
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- var writer = new FileWriter(playerDatFile);
- writer.write(gson.toJson(EMPTYPLAYERDATA));
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static class PlayerData {
- @SerializedName("branches")
- public static Map<String, Boolean> branches = new HashMap<>();
- @SerializedName("skills")
- public static Map<String, Integer> skills = new HashMap<>();
-
- public PlayerData() {}
- }
-
- public static class EmptyPlayerData {
- @SerializedName("branches")
- public static Map<String, Boolean> branches = new HashMap<>();
- @SerializedName("skills")
- public static Map<String, Integer> skills = new HashMap<>();
-
- public EmptyPlayerData() {}
- }
-} \ No newline at end of file
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/advancements/Advancements.java b/src/main/java/dev/mayaqq/ygasi/registry/advancements/Advancements.java
new file mode 100644
index 0000000..ac33abe
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/registry/advancements/Advancements.java
@@ -0,0 +1,76 @@
+package dev.mayaqq.ygasi.registry.advancements;
+
+import de.dafuqs.revelationary.advancement_criteria.AdvancementGottenCriterion;
+import net.minecraft.advancement.Advancement;
+import net.minecraft.advancement.AdvancementFrame;
+import net.minecraft.advancement.criterion.ImpossibleCriterion;
+import net.minecraft.item.Items;
+import net.minecraft.predicate.entity.EntityPredicate;
+import net.minecraft.text.Text;
+import net.minecraft.util.Identifier;
+
+import java.util.function.Consumer;
+
+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())
+ .build(consumer, "ygasi" + "/root");
+
+ 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()))
+ .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()))
+ .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()))
+ .build(consumer, "ygasi" + "/druidry");
+ }
+} \ No newline at end of file
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/AdvancementProvider.java b/src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/AdvancementProvider.java
new file mode 100644
index 0000000..a9b1a64
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/AdvancementProvider.java
@@ -0,0 +1,18 @@
+package dev.mayaqq.ygasi.registry.advancements.dataGen;
+
+import dev.mayaqq.ygasi.registry.advancements.Advancements;
+import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
+import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
+import net.minecraft.advancement.Advancement;
+
+import java.util.function.Consumer;
+
+public class AdvancementProvider extends FabricAdvancementProvider {
+ protected AdvancementProvider(FabricDataGenerator dataGenerator) {
+ super(dataGenerator);
+ }
+ @Override
+ public void generateAdvancement(Consumer<Advancement> consumer) {
+ new Advancements().accept(consumer);
+ }
+}
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/DataGenRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/DataGenRegistry.java
index a060c42..9bba67d 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/DataGenRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/advancements/dataGen/DataGenRegistry.java
@@ -1,4 +1,4 @@
-package dev.mayaqq.ygasi.registry;
+package dev.mayaqq.ygasi.registry.advancements.dataGen;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
@@ -6,6 +6,6 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
public class DataGenRegistry implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
-
+ dataGenerator.addProvider(AdvancementProvider::new);
}
}