aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-11 19:50:29 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-11 19:50:29 +0100
commit5bcb1830298caad87a63f44c4e7f1553074cf4c8 (patch)
treec0c193496f96a201ecd8b3ce44c24fd0ac0d6214 /src
parent5e48daa137cda5043ebce80b7e3e975da2d7c069 (diff)
downloadygasi-5bcb1830298caad87a63f44c4e7f1553074cf4c8.tar.gz
ygasi-5bcb1830298caad87a63f44c4e7f1553074cf4c8.tar.bz2
ygasi-5bcb1830298caad87a63f44c4e7f1553074cf4c8.zip
Made everything work on 1.19.3, wasnt that bad after all!
Diffstat (limited to 'src')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/Ygasi.java2
-rw-r--r--src/main/java/dev/mayaqq/ygasi/dataGen/DataGenRegistry.java9
-rw-r--r--src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancementProvider.java (renamed from src/main/java/dev/mayaqq/ygasi/dataGen/advancements/AdvancementProvider.java)10
-rw-r--r--src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancements.java (renamed from src/main/java/dev/mayaqq/ygasi/dataGen/advancements/Advancements.java)2
-rw-r--r--src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipesProvider.java (renamed from src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipes.java)15
-rw-r--r--src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java2
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java6
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java22
-rw-r--r--src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java11
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java27
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/StatRegistry.java2
-rw-r--r--src/main/resources/fabric.mod.json2
12 files changed, 57 insertions, 53 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/Ygasi.java b/src/main/java/dev/mayaqq/ygasi/Ygasi.java
index a6a07c6..608472a 100644
--- a/src/main/java/dev/mayaqq/ygasi/Ygasi.java
+++ b/src/main/java/dev/mayaqq/ygasi/Ygasi.java
@@ -3,11 +3,13 @@ package dev.mayaqq.ygasi;
import dev.mayaqq.ygasi.registry.*;
import dev.mayaqq.ygasi.secrete.Frog;
import net.fabricmc.api.ModInitializer;
+import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Ygasi implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("ygasi");
+ public static Identifier click = new Identifier("ui.button.click");
@Override
public void onInitialize() {
diff --git a/src/main/java/dev/mayaqq/ygasi/dataGen/DataGenRegistry.java b/src/main/java/dev/mayaqq/ygasi/dataGen/DataGenRegistry.java
index 1e78016..7efe8e6 100644
--- a/src/main/java/dev/mayaqq/ygasi/dataGen/DataGenRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/dataGen/DataGenRegistry.java
@@ -1,14 +1,15 @@
package dev.mayaqq.ygasi.dataGen;
-import dev.mayaqq.ygasi.dataGen.advancements.AdvancementProvider;
-import dev.mayaqq.ygasi.dataGen.recipes.YgasiRecipes;
+import dev.mayaqq.ygasi.dataGen.advancements.YgasiAdvancementProvider;
+import dev.mayaqq.ygasi.dataGen.recipes.YgasiRecipesProvider;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
public class DataGenRegistry implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
- dataGenerator.addProvider(AdvancementProvider::new);
- dataGenerator.addProvider(YgasiRecipes::new);
+ FabricDataGenerator.Pack pack = dataGenerator.createPack();
+ pack.addProvider(YgasiAdvancementProvider::new);
+ pack.addProvider(YgasiRecipesProvider::new);
}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/AdvancementProvider.java b/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancementProvider.java
index 1944d4b..77eea7d 100644
--- a/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/AdvancementProvider.java
+++ b/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancementProvider.java
@@ -1,17 +1,17 @@
package dev.mayaqq.ygasi.dataGen.advancements;
-import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
+import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
import net.minecraft.advancement.Advancement;
import java.util.function.Consumer;
-public class AdvancementProvider extends FabricAdvancementProvider {
- public AdvancementProvider(FabricDataGenerator dataGenerator) {
- super(dataGenerator);
+public class YgasiAdvancementProvider extends FabricAdvancementProvider {
+ public YgasiAdvancementProvider(FabricDataOutput output) {
+ super(output);
}
@Override
public void generateAdvancement(Consumer<Advancement> consumer) {
- new Advancements().accept(consumer);
+ new YgasiAdvancements().accept(consumer);
}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/Advancements.java b/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancements.java
index 8c0d5f5..70fc642 100644
--- a/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/Advancements.java
+++ b/src/main/java/dev/mayaqq/ygasi/dataGen/advancements/YgasiAdvancements.java
@@ -12,7 +12,7 @@ import net.minecraft.util.Identifier;
import java.util.function.Consumer;
-public class Advancements implements Consumer<Consumer<Advancement>> {
+public class YgasiAdvancements implements Consumer<Consumer<Advancement>> {
@Override
public void accept(Consumer<Advancement> consumer) {
diff --git a/src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipes.java b/src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipesProvider.java
index 032cc2e..8f9e12d 100644
--- a/src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipes.java
+++ b/src/main/java/dev/mayaqq/ygasi/dataGen/recipes/YgasiRecipesProvider.java
@@ -1,25 +1,26 @@
package dev.mayaqq.ygasi.dataGen.recipes;
-import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
+import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.advancement.criterion.ImpossibleCriterion;
import net.minecraft.data.server.recipe.RecipeJsonProvider;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.item.Items;
-import net.minecraft.tag.ItemTags;
+import net.minecraft.recipe.book.RecipeCategory;
+import net.minecraft.registry.tag.ItemTags;
import java.util.function.Consumer;
import static dev.mayaqq.ygasi.registry.ItemRegistry.SKILL_BOOK;
-public class YgasiRecipes extends FabricRecipeProvider {
- public YgasiRecipes(FabricDataGenerator dataGenerator) {
- super(dataGenerator);
+public class YgasiRecipesProvider extends FabricRecipeProvider {
+ public YgasiRecipesProvider(FabricDataOutput output) {
+ super(output);
}
@Override
- public void generateRecipes(Consumer<RecipeJsonProvider> exporter) {
- ShapelessRecipeJsonBuilder.create(SKILL_BOOK)
+ public void generate(Consumer<RecipeJsonProvider> exporter) {
+ ShapelessRecipeJsonBuilder.create(RecipeCategory.MISC, SKILL_BOOK)
.criterion("has_book", new ImpossibleCriterion.Conditions())
.input(Items.BOOK)
.input(ItemTags.SAPLINGS)
diff --git a/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java b/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
index 7836ca6..34f5f46 100644
--- a/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
+++ b/src/main/java/dev/mayaqq/ygasi/events/PlayerConnectEvent.java
@@ -2,10 +2,12 @@ package dev.mayaqq.ygasi.events;
import dev.mayaqq.ygasi.registry.ConfigRegistry;
import dev.mayaqq.ygasi.util.AdvUtils;
+import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
+import static dev.mayaqq.ygasi.Ygasi.LOGGER;
import static dev.mayaqq.ygasi.registry.ItemRegistry.SKILL_BOOK;
public class PlayerConnectEvent {
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
index d293f47..eca0226 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
@@ -146,9 +146,9 @@ public class BranchGui {
}
//this happens when you try to unlock a branch
public static void save(ServerPlayerEntity player, String branch, String branchName) {
- Boolean hasMercenary = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary");
- Boolean hasWizadry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry");
- Boolean hasDrudiry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry");
+ boolean hasMercenary = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary");
+ boolean hasWizadry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry");
+ boolean hasDrudiry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry");
//special category for extra branch because it's half the price
if (branch.equals("extra")) {
if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost / 2) {
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
index c9f0383..74c1c5e 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
@@ -8,9 +8,11 @@ import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
-import net.minecraft.sound.SoundEvents;
+import net.minecraft.sound.SoundEvent;
import net.minecraft.text.Text;
+import static dev.mayaqq.ygasi.Ygasi.click;
+
public class ConfigGui {
public static void gui(ServerPlayerEntity player) {
@@ -30,7 +32,6 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.pointsRewarded))))
.setCallback((index, clickType, actionType) -> {
textInput(player, "pointsRewarded");
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -40,7 +41,6 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.branchCost))))
.setCallback((index, clickType, actionType) -> {
textInput(player, "branchCost");
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -50,9 +50,9 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.enableSkillBook))))
.setCallback((index, clickType, actionType) -> {
ConfigRegistry.CONFIG.enableSkillBook = !ConfigRegistry.CONFIG.enableSkillBook;
+ player.playSound(SoundEvent.of(click), SoundCategory.PLAYERS, 1.0F, 1.0F);
gui.close();
gui(player);
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -62,7 +62,6 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.T1Cost))))
.setCallback((index, clickType, actionType) -> {
textInput(player, "T1Cost");
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -73,7 +72,6 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.T2Cost))))
.setCallback((index, clickType, actionType) -> {
textInput(player, "T2Cost");
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -84,7 +82,6 @@ public class ConfigGui {
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.T3Cost))))
.setCallback((index, clickType, actionType) -> {
textInput(player, "T3Cost");
- player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.PLAYERS, 1.0F, 1.0F);
})
);
@@ -92,6 +89,7 @@ public class ConfigGui {
}
private static void textInput(ServerPlayerEntity player, String option) {
+ player.playSound(SoundEvent.of(click), SoundCategory.PLAYERS, 1.0F, 1.0F);
try {
SignGui gui = new SignGui(player) {
@Override
@@ -101,35 +99,35 @@ public class ConfigGui {
try {
ConfigRegistry.CONFIG.pointsRewarded = Integer.parseInt(this.getLine(0).getString());
} catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), false);
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
}
case "branchCost" -> {
try {
ConfigRegistry.CONFIG.branchCost = Integer.parseInt(this.getLine(0).getString());
} catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), false);
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
}
case "T1Cost" -> {
try {
ConfigRegistry.CONFIG.T1Cost = Integer.parseInt(this.getLine(0).getString());
} catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), false);
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
}
case "T2Cost" -> {
try {
ConfigRegistry.CONFIG.T2Cost = Integer.parseInt(this.getLine(0).getString());
} catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), false);
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
}
case "T3Cost" -> {
try {
ConfigRegistry.CONFIG.T3Cost = Integer.parseInt(this.getLine(0).getString());
} catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), false);
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java b/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java
index 9376277..51f0292 100644
--- a/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java
+++ b/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java
@@ -1,8 +1,8 @@
package dev.mayaqq.ygasi.items;
import dev.mayaqq.ygasi.gui.BranchGui;
-import eu.pb4.polymer.api.item.PolymerItemUtils;
-import eu.pb4.polymer.api.item.SimplePolymerItem;
+import eu.pb4.polymer.core.api.item.PolymerItemUtils;
+import eu.pb4.polymer.core.api.item.SimplePolymerItem;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
@@ -25,11 +25,6 @@ public class SkillBookItem extends SimplePolymerItem {
}
@Override
- public ItemStack getPolymerItemStack(ItemStack itemStack, ServerPlayerEntity player) {
- return PolymerItemUtils.createItemStack(itemStack, player);
- }
-
- @Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
ServerPlayerEntity player = (ServerPlayerEntity) playerEntity;
BranchGui.gui(player);
@@ -38,7 +33,7 @@ public class SkillBookItem extends SimplePolymerItem {
@Override
public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
- return 1;
+ return 2;
}
@Override
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
index 61cb93d..06f3196 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/ItemRegistry.java
@@ -1,25 +1,30 @@
package dev.mayaqq.ygasi.registry;
import dev.mayaqq.ygasi.items.SkillBookItem;
-import eu.pb4.polymer.api.item.PolymerItemGroup;
-import eu.pb4.polymer.api.resourcepack.PolymerModelData;
-import eu.pb4.polymer.api.resourcepack.PolymerRPUtils;
+import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils;
+import eu.pb4.polymer.resourcepack.api.PolymerModelData;
+import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
+import net.minecraft.registry.Registries;
+import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
-import net.minecraft.util.registry.Registry;
public class ItemRegistry {
- public static final PolymerItemGroup YGASI_GROUP = PolymerItemGroup.create(new Identifier("ygasi"), Text.translatable("creative.ygasi.group"), () -> new ItemStack(Items.BOOK));
-
- public static final SkillBookItem SKILL_BOOK = new SkillBookItem(new Item.Settings().group(YGASI_GROUP).maxCount(1), Items.BOOK);
+ public static final SkillBookItem SKILL_BOOK = new SkillBookItem(new Item.Settings().maxCount(1), Items.BOOK);
public static void register() {
- PolymerRPUtils.addAssetSource("ygasi");
-
- PolymerModelData skillBookModelData = PolymerRPUtils.requestModel(Items.BOOK, new Identifier("ygasi", "item/skill_book"));
+ PolymerItemGroupUtils.builder(new Identifier("ygasi", "ygasi"))
+ .displayName(Text.translatable("creative.ygasi.group"))
+ .icon(() -> new ItemStack(Items.BOOK))
+ .entries((enabledFeatures, entries, operatorEnabled) -> {
+ entries.add(SKILL_BOOK);
+ })
+ .build();
+ PolymerResourcePackUtils.addModAssets("ygasi");
+ PolymerModelData skillBookModelData = PolymerResourcePackUtils.requestModel(Items.BOOK, new Identifier("ygasi", "item/skill_book"));
- Registry.register(Registry.ITEM, "ygasi:skill_book", SKILL_BOOK);
+ Registry.register(Registries.ITEM, new Identifier("ygasi", "skill_book"), SKILL_BOOK);
}
}
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/StatRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/StatRegistry.java
index 039b0b6..5d095ba 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/StatRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/StatRegistry.java
@@ -1,6 +1,6 @@
package dev.mayaqq.ygasi.registry;
-import eu.pb4.polymer.api.other.PolymerStat;
+import eu.pb4.polymer.core.api.other.PolymerStat;
import net.minecraft.stat.StatFormatter;
import net.minecraft.util.Identifier;
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 656a474..929040c 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -19,7 +19,7 @@
"environment": "server",
"entrypoints": {
"fabric-datagen": [
- "dev.mayaqq.ygasi.registry.dataGen.DataGenRegistry"
+ "dev.mayaqq.ygasi.dataGen.DataGenRegistry"
],
"main": [
"dev.mayaqq.ygasi.Ygasi"