aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/registry
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-15 18:40:24 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-15 18:40:24 +0100
commitd115e4365d0a5a492a55e56a7a4dcf034419e1b4 (patch)
treee9aec4f8b180c4a6b90d194f31e95a8df8863bb4 /src/main/java/dev/mayaqq/ygasi/registry
parent5bcb1830298caad87a63f44c4e7f1553074cf4c8 (diff)
downloadygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.gz
ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.bz2
ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.zip
More stuff! The Mercenary gui is basically done other than the translations, I tried and failed to add modrinth publishing thing to gradle, I redid some stuff, I added stuff, I removed stuff and mainly... I broke the reset command (it works but says it broke) and I have no idea how to fix it!
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/registry')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java23
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java4
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java7
3 files changed, 23 insertions, 11 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
index 781ef4d..2b29a3c 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
@@ -1,5 +1,6 @@
package dev.mayaqq.ygasi.registry;
+import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.context.CommandContext;
import dev.mayaqq.ygasi.gui.*;
@@ -15,6 +16,7 @@ import net.minecraft.util.Formatting;
import java.io.File;
+import static dev.mayaqq.ygasi.Ygasi.LOGGER;
import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS_TOTAL;
import static net.minecraft.server.command.CommandManager.literal;
@@ -53,12 +55,19 @@ public class CommandRegistry {
.requires(source -> source.hasPermissionLevel(4))
.then(literal("skillpoints")
.then(literal("reset")
- .then(CommandManager.argument("target", EntityArgumentType.player())
+ .then(CommandManager.argument("targets", EntityArgumentType.players())
.executes(context -> {
- ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target");
- player.resetStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS));
- player.resetStat(Stats.CUSTOM.getOrCreateStat(StatRegistry.SKILL_POINTS_TOTAL));
- player.sendMessage(Text.translatable("commands.ygasi.skillpoints.reset", player.getEntityName()).formatted(Formatting.GREEN));
+ for (int i = 0; i <= EntityArgumentType.getPlayers(context, "targets").size(); i++) {
+ ServerPlayerEntity[] players = EntityArgumentType.getPlayers(context, "targets").toArray(new ServerPlayerEntity[0]);
+ ResetGui.reset(players[i]);
+ }
+ String players;
+ if (EntityArgumentType.getPlayers(context, "targets").size() == 1) {
+ players = EntityArgumentType.getPlayers(context, "targets").toArray()[0].toString();
+ } else {
+ players = EntityArgumentType.getPlayers(context, "targets").size() + " players";
+ }
+ context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.reset", players).formatted(Formatting.GREEN));
return 1;
})))
.then(literal("add")
@@ -69,14 +78,14 @@ public class CommandRegistry {
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target");
player.increaseStat(SKILL_POINTS, amount);
player.increaseStat(SKILL_POINTS_TOTAL, amount);
- player.sendMessage(Text.translatable("commands.ygasi.skillpoints.add", amount, player.getName()).formatted(Formatting.GREEN));
+ context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.add", amount, player.getName()).formatted(Formatting.GREEN));
return 1;
}))))
.then(literal("get")
.then(CommandManager.argument("target", EntityArgumentType.player())
.executes(context -> {
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "target");
- player.sendMessage(Text.translatable("commands.ygasi.skillpoints.get", player.getEntityName(), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))).formatted(Formatting.GREEN));
+ context.getSource().sendMessage(Text.translatable("commands.ygasi.skillpoints.get", player.getEntityName(), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))).formatted(Formatting.GREEN));
return 1;
}))))
.then(literal("config")
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
index 2c939b3..c48cd6e 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
@@ -11,7 +11,7 @@ public class ConfigRegistry {
public static Config CONFIG = new Config();
static File modConfFolder = new File(FabricLoader.getInstance().getConfigDir().toFile(),"ygasi");
- private static File configFile = new File(modConfFolder,"config.json");
+ private static final File configFile = new File(modConfFolder,"config.json");
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public static void load() {
@@ -50,9 +50,11 @@ public class ConfigRegistry {
public int pointsRewarded = 1;
public int branchCost = 16;
public Boolean enableSkillBook = true;
+ public int resetCost = 10;
public int T1Cost = 5;
public int T2Cost = 10;
public int T3Cost = 15;
+ public int offence1DefIncrease = 3;
public Config() {}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
index 06f3196..145a063 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
@@ -13,8 +13,10 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class ItemRegistry {
- public static final SkillBookItem SKILL_BOOK = new SkillBookItem(new Item.Settings().maxCount(1), Items.BOOK);
+ public static final SkillBookItem SKILL_BOOK = Registry.register(Registries.ITEM, new Identifier("ygasi", "skill_book"), new SkillBookItem(new Item.Settings().maxCount(1), Items.BOOK));
+
public static void register() {
+ //Register item group
PolymerItemGroupUtils.builder(new Identifier("ygasi", "ygasi"))
.displayName(Text.translatable("creative.ygasi.group"))
.icon(() -> new ItemStack(Items.BOOK))
@@ -22,9 +24,8 @@ public class ItemRegistry {
entries.add(SKILL_BOOK);
})
.build();
+ //Register item model
PolymerResourcePackUtils.addModAssets("ygasi");
PolymerModelData skillBookModelData = PolymerResourcePackUtils.requestModel(Items.BOOK, new Identifier("ygasi", "item/skill_book"));
-
- Registry.register(Registries.ITEM, new Identifier("ygasi", "skill_book"), SKILL_BOOK);
}
}