diff --git a/gradle.properties b/gradle.properties index 6360ac7..f488b0d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ name = Micle's Totem of Reviving author = Micle buildVersion = 2.0.0 -mcVersion = 1.19.2 -forgeVersion = 43.1.47 +mcVersion = 1.19.4 +forgeVersion = 45.2.8 -jeiVersion = 11.+ +#jeiVersion = 11.+ diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/diamond_charge.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/diamond_charge.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/diamond_charge.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/diamond_charge.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/diamond_totem.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/diamond_totem.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/diamond_totem.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/diamond_totem.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/iron_charge.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/iron_charge.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/iron_charge.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/iron_charge.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/iron_totem.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/iron_totem.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/iron_totem.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/iron_totem.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/netherite_charge.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/netherite_charge.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/netherite_charge.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/netherite_charge.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/netherite_totem.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/netherite_totem.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/netherite_totem.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/netherite_totem.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/straw_charge.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/straw_charge.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/straw_charge.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/straw_charge.json diff --git a/src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/straw_totem.json b/src/generated/resources/data/totemofreviving/advancements/recipes/tools/straw_totem.json similarity index 100% rename from src/generated/resources/data/totemofreviving/advancements/recipes/totemofreviving/straw_totem.json rename to src/generated/resources/data/totemofreviving/advancements/recipes/tools/straw_totem.json diff --git a/src/generated/resources/data/totemofreviving/recipes/diamond_charge.json b/src/generated/resources/data/totemofreviving/recipes/diamond_charge.json index c2055c8..5e5d63f 100644 --- a/src/generated/resources/data/totemofreviving/recipes/diamond_charge.json +++ b/src/generated/resources/data/totemofreviving/recipes/diamond_charge.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:charge_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "D": { "item": "minecraft:diamond" @@ -21,5 +22,6 @@ ], "result": { "item": "totemofreviving:diamond_charge" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/diamond_totem.json b/src/generated/resources/data/totemofreviving/recipes/diamond_totem.json index e93c8c4..0a3cbe7 100644 --- a/src/generated/resources/data/totemofreviving/recipes/diamond_totem.json +++ b/src/generated/resources/data/totemofreviving/recipes/diamond_totem.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:totem_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "D": { "item": "minecraft:diamond" @@ -18,5 +19,6 @@ ], "result": { "item": "totemofreviving:diamond_totem" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/iron_charge.json b/src/generated/resources/data/totemofreviving/recipes/iron_charge.json index f44eb51..2a6fed9 100644 --- a/src/generated/resources/data/totemofreviving/recipes/iron_charge.json +++ b/src/generated/resources/data/totemofreviving/recipes/iron_charge.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:charge_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "E": { "item": "minecraft:emerald" @@ -18,5 +19,6 @@ ], "result": { "item": "totemofreviving:iron_charge" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/iron_totem.json b/src/generated/resources/data/totemofreviving/recipes/iron_totem.json index 3b6b512..f564102 100644 --- a/src/generated/resources/data/totemofreviving/recipes/iron_totem.json +++ b/src/generated/resources/data/totemofreviving/recipes/iron_totem.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:totem_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "B": { "item": "minecraft:iron_block" @@ -18,5 +19,6 @@ ], "result": { "item": "totemofreviving:iron_totem" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/netherite_charge.json b/src/generated/resources/data/totemofreviving/recipes/netherite_charge.json index a596dc5..3622fcc 100644 --- a/src/generated/resources/data/totemofreviving/recipes/netherite_charge.json +++ b/src/generated/resources/data/totemofreviving/recipes/netherite_charge.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:charge_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "C": { "item": "totemofreviving:diamond_charge" @@ -18,5 +19,6 @@ ], "result": { "item": "totemofreviving:netherite_charge" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/netherite_totem.json b/src/generated/resources/data/totemofreviving/recipes/netherite_totem.json index 417f2dc..1d4f243 100644 --- a/src/generated/resources/data/totemofreviving/recipes/netherite_totem.json +++ b/src/generated/resources/data/totemofreviving/recipes/netherite_totem.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:totem_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "B": { "item": "minecraft:nether_brick" @@ -21,5 +22,6 @@ ], "result": { "item": "totemofreviving:netherite_totem" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/straw_charge.json b/src/generated/resources/data/totemofreviving/recipes/straw_charge.json index 3fce551..785551c 100644 --- a/src/generated/resources/data/totemofreviving/recipes/straw_charge.json +++ b/src/generated/resources/data/totemofreviving/recipes/straw_charge.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:charge_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "E": { "item": "minecraft:emerald" @@ -18,5 +19,6 @@ ], "result": { "item": "totemofreviving:straw_charge" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/generated/resources/data/totemofreviving/recipes/straw_totem.json b/src/generated/resources/data/totemofreviving/recipes/straw_totem.json index 84c65cf..4ce2287 100644 --- a/src/generated/resources/data/totemofreviving/recipes/straw_totem.json +++ b/src/generated/resources/data/totemofreviving/recipes/straw_totem.json @@ -1,5 +1,6 @@ { - "type": "totemofreviving:totem_recipe", + "type": "minecraft:crafting_shaped", + "category": "equipment", "key": { "N": { "item": "minecraft:iron_nugget" @@ -21,5 +22,6 @@ ], "result": { "item": "totemofreviving:straw_totem" - } + }, + "show_notification": true } \ No newline at end of file diff --git a/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java b/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java index fbfd52c..f038785 100644 --- a/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java +++ b/src/main/java/dev/micle/totemofreviving/TotemOfReviving.java @@ -1,12 +1,10 @@ package dev.micle.totemofreviving; -import dev.micle.totemofreviving.proxy.IProxy; import dev.micle.totemofreviving.proxy.IProxy; import dev.micle.totemofreviving.proxy.Proxy; -import dev.micle.totemofreviving.setup.ModItems; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; @@ -17,12 +15,7 @@ import java.util.Optional; @Mod(TotemOfReviving.MOD_ID) public final class TotemOfReviving { public static final String MOD_ID = "totemofreviving"; - public static final CreativeModeTab ITEM_GROUP = new CreativeModeTab(MOD_ID) { - @Override - public ItemStack makeIcon() { - return new ItemStack(ModItems.STRAW_TOTEM.get()); - } - }; + public static CreativeModeTab CREATIVE_TAB = CreativeModeTabs.getDefaultTab(); private static IProxy proxy; diff --git a/src/main/java/dev/micle/totemofreviving/data/ModRecipeProvider.java b/src/main/java/dev/micle/totemofreviving/data/ModRecipeProvider.java index e49d560..7596f8f 100644 --- a/src/main/java/dev/micle/totemofreviving/data/ModRecipeProvider.java +++ b/src/main/java/dev/micle/totemofreviving/data/ModRecipeProvider.java @@ -1,11 +1,11 @@ package dev.micle.totemofreviving.data; -import dev.micle.totemofreviving.item.crafting.ExtendedShapedRecipeBuilder; import dev.micle.totemofreviving.setup.ModItems; -import dev.micle.totemofreviving.setup.ModRecipes; import net.minecraft.data.DataGenerator; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.world.item.Items; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,13 +13,13 @@ import java.util.function.Consumer; public class ModRecipeProvider extends RecipeProvider { public ModRecipeProvider(DataGenerator generator) { - super(generator); + super(generator.getPackOutput()); } - + @Override @ParametersAreNonnullByDefault - protected void buildCraftingRecipes(Consumer consumer) { - ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.STRAW_TOTEM.get()) + protected void buildRecipes(Consumer consumer) { + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.STRAW_TOTEM.get()) .define('W', Items.WHEAT) .define('|', Items.STICK) .define('S', Items.STRING) @@ -29,7 +29,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("N|N") .unlockedBy("has_item", has(Items.WHEAT)) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.IRON_TOTEM.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.IRON_TOTEM.get()) .define('B', Items.IRON_BLOCK) .define('E', Items.EMERALD) .define('I', Items.IRON_INGOT) @@ -38,7 +38,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern(" I ") .unlockedBy("has_item", has(Items.EMERALD)) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.DIAMOND_TOTEM.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.DIAMOND_TOTEM.get()) .define('T', Items.TOTEM_OF_UNDYING) .define('D', Items.DIAMOND) .define('E', Items.ENDER_PEARL) @@ -47,7 +47,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("EDE") .unlockedBy("has_item", has(Items.TOTEM_OF_UNDYING)) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.TOTEM_RECIPE.get(), ModItems.NETHERITE_TOTEM.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.NETHERITE_TOTEM.get()) .define('T', ModItems.DIAMOND_TOTEM.get()) .define('N', Items.NETHERITE_SCRAP) .define('G', Items.GOLD_INGOT) @@ -57,8 +57,8 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("BGB") .unlockedBy("has_item", has(Items.NETHERITE_SCRAP)) .save(consumer); - - ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.STRAW_CHARGE.get()) + + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.STRAW_CHARGE.get()) .define('E', Items.EMERALD) .define('W', Items.WHEAT) .define('N', Items.IRON_NUGGET) @@ -67,7 +67,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("NWN") .unlockedBy("has_item", has(ModItems.STRAW_TOTEM.get())) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.IRON_CHARGE.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.IRON_CHARGE.get()) .define('E', Items.EMERALD) .define('I', Items.IRON_INGOT) .define('N', Items.IRON_NUGGET) @@ -76,7 +76,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("NIN") .unlockedBy("has_item", has(ModItems.IRON_TOTEM.get())) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.DIAMOND_CHARGE.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.DIAMOND_CHARGE.get()) .define('E', Items.EMERALD) .define('D', Items.DIAMOND) .define('I', Items.IRON_INGOT) @@ -86,7 +86,7 @@ public class ModRecipeProvider extends RecipeProvider { .pattern("IDI") .unlockedBy("has_item", has(ModItems.DIAMOND_TOTEM.get())) .save(consumer); - ExtendedShapedRecipeBuilder.shaped(ModRecipes.CHARGE_RECIPE.get(), ModItems.NETHERITE_CHARGE.get()) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.NETHERITE_CHARGE.get()) .define('C', ModItems.DIAMOND_CHARGE.get()) .define('N', Items.NETHERITE_SCRAP) .define('G', Items.GOLD_INGOT) diff --git a/src/main/java/dev/micle/totemofreviving/data/client/ModItemModelProvider.java b/src/main/java/dev/micle/totemofreviving/data/client/ModItemModelProvider.java index e37fa0a..e0f0c86 100644 --- a/src/main/java/dev/micle/totemofreviving/data/client/ModItemModelProvider.java +++ b/src/main/java/dev/micle/totemofreviving/data/client/ModItemModelProvider.java @@ -17,7 +17,7 @@ import net.minecraftforge.common.data.ExistingFileHelper; public class ModItemModelProvider extends ItemModelProvider { public ModItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, TotemOfReviving.MOD_ID, existingFileHelper); + super(generator.getPackOutput(), TotemOfReviving.MOD_ID, existingFileHelper); } @Override diff --git a/src/main/java/dev/micle/totemofreviving/event/common/OnCreativeModeTabRegisterEventHandler.java b/src/main/java/dev/micle/totemofreviving/event/common/OnCreativeModeTabRegisterEventHandler.java new file mode 100644 index 0000000..7e874ae --- /dev/null +++ b/src/main/java/dev/micle/totemofreviving/event/common/OnCreativeModeTabRegisterEventHandler.java @@ -0,0 +1,33 @@ +package dev.micle.totemofreviving.event.common; + +import dev.micle.totemofreviving.TotemOfReviving; +import dev.micle.totemofreviving.setup.ModItems; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +@Mod.EventBusSubscriber(modid = TotemOfReviving.MOD_ID) +public class OnCreativeModeTabRegisterEventHandler { + @SubscribeEvent + public static void creativeModeTabRegisterEvent(CreativeModeTabEvent.Register event) { + System.out.println("HERE!"); + TotemOfReviving.CREATIVE_TAB = event.registerCreativeModeTab( + TotemOfReviving.createResourceLocation("creative_mode_tab_main"), builder -> builder + .icon(() -> new ItemStack(ModItems.STRAW_TOTEM.get())) + .title(Component.translatable(String.format("tabs.%s.main_tab", TotemOfReviving.MOD_ID))) + .displayItems((featureFlags, output) -> { + output.accept(ModItems.STRAW_TOTEM.get()); + output.accept(ModItems.IRON_TOTEM.get()); + output.accept(ModItems.DIAMOND_TOTEM.get()); + output.accept(ModItems.NETHERITE_TOTEM.get()); + + output.accept(ModItems.STRAW_CHARGE.get()); + output.accept(ModItems.IRON_CHARGE.get()); + output.accept(ModItems.DIAMOND_CHARGE.get()); + output.accept(ModItems.NETHERITE_CHARGE.get()); + }) + ); + } +} diff --git a/src/main/java/dev/micle/totemofreviving/item/charge/ChargeItem.java b/src/main/java/dev/micle/totemofreviving/item/charge/ChargeItem.java index 005727e..c2bdeef 100644 --- a/src/main/java/dev/micle/totemofreviving/item/charge/ChargeItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/charge/ChargeItem.java @@ -1,6 +1,5 @@ package dev.micle.totemofreviving.item.charge; -import dev.micle.totemofreviving.TotemOfReviving; import dev.micle.totemofreviving.setup.Config; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -22,27 +21,14 @@ public class ChargeItem extends Item { } public ChargeItem(Rarity rarity) { - super(new Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(64).rarity(rarity)); + super(new Properties().stacksTo(64).rarity(rarity)); } @Override @OnlyIn(Dist.CLIENT) @ParametersAreNonnullByDefault public void appendHoverText(ItemStack stack, @Nullable Level world, List tooltip, TooltipFlag tooltipFlag) { - if (isEnabled(stack)) { - tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem.")); - } else { - tooltip.add(Component.literal(ChatFormatting.RED + "Totem is disabled!")); - } + tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem.")); super.appendHoverText(stack, world, tooltip, tooltipFlag); } - - public static boolean isEnabled(ItemStack stack) { - Item item = stack.getItem(); - if (item instanceof StrawChargeItem) { return Config.Server.getStrawTotemConfig().getIsEnabled(); } - if (item instanceof IronChargeItem) { return Config.Server.getIronTotemConfig().getIsEnabled(); } - if (item instanceof DiamondChargeItem) { return Config.Server.getDiamondTotemConfig().getIsEnabled(); } - if (item instanceof NetheriteChargeItem) { return Config.Server.getNetheriteTotemConfig().getIsEnabled(); } - return false; - } } diff --git a/src/main/java/dev/micle/totemofreviving/item/crafting/ChargeRecipe.java b/src/main/java/dev/micle/totemofreviving/item/crafting/ChargeRecipe.java deleted file mode 100644 index 19c678e..0000000 --- a/src/main/java/dev/micle/totemofreviving/item/crafting/ChargeRecipe.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.micle.totemofreviving.item.crafting; - -import dev.micle.totemofreviving.item.charge.ChargeItem; -import dev.micle.totemofreviving.setup.ModRecipes; -import net.minecraft.world.inventory.CraftingContainer; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.level.Level; - -public class ChargeRecipe extends ExtendedShapedRecipe { - public ChargeRecipe(ShapedRecipe recipe) { - super(recipe); - } - - @Override - public RecipeSerializer getSerializer() { - return ModRecipes.CHARGE_RECIPE.get(); - } - - @Override - public boolean matches(CraftingContainer inventory, Level world) { - if (!ChargeItem.isEnabled(getResultItem())) { - return false; - } - return getBaseRecipe().matches(inventory, world); - } - - @Override - public ItemStack assemble(CraftingContainer inventory) { - return getBaseRecipe().getResultItem().copy(); - } -} diff --git a/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipe.java b/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipe.java deleted file mode 100644 index 6ffaab8..0000000 --- a/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipe.java +++ /dev/null @@ -1,87 +0,0 @@ -package dev.micle.totemofreviving.item.crafting; - -import com.google.gson.JsonObject; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.inventory.CraftingContainer; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.level.Level; - -import javax.annotation.Nullable; -import java.util.function.BiConsumer; -import java.util.function.Function; - -public abstract class ExtendedShapedRecipe extends ShapedRecipe { - private static final RecipeSerializer BASE_SERIALIZER = RecipeSerializer.SHAPED_RECIPE; - - private final ShapedRecipe recipe; - - public ExtendedShapedRecipe(ShapedRecipe recipe) { - super(recipe.getId(), recipe.getGroup(), recipe.getRecipeWidth(), recipe.getRecipeHeight(), recipe.getIngredients(), recipe.getResultItem()); - this.recipe = recipe; - } - - public ShapedRecipe getBaseRecipe() { - return this.recipe; - } - - @Override - public abstract RecipeSerializer getSerializer(); - - @Override - public abstract boolean matches(CraftingContainer inventory, Level world); - - @Override - public abstract ItemStack assemble(CraftingContainer inventory); - - public static class Serializer implements RecipeSerializer { - private final Function recipeFactory; - @Nullable private final BiConsumer readJson; - @Nullable private final BiConsumer readBuffer; - @Nullable private final BiConsumer writeBuffer; - - public Serializer(Function recipeFactory, - @Nullable BiConsumer readJson, - @Nullable BiConsumer readBuffer, - @Nullable BiConsumer writeBuffer) { - this.recipeFactory = recipeFactory; - this.readJson = readJson; - this.readBuffer = readBuffer; - this.writeBuffer = writeBuffer; - } - - public static Serializer basic(Function recipeFactory) { - return new Serializer<>(recipeFactory, null, null, null); - } - - @Override - public T fromJson(ResourceLocation recipeId, JsonObject json) { - ShapedRecipe recipe = BASE_SERIALIZER.fromJson(recipeId, json); - T result = this.recipeFactory.apply(recipe); - if (this.readJson != null) { - this.readJson.accept(json, result); - } - return result; - } - - @Override - public T fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { - ShapedRecipe recipe = BASE_SERIALIZER.fromNetwork(recipeId, buffer); - T result = this.recipeFactory.apply(recipe); - if (this.readBuffer != null) { - this.readBuffer.accept(buffer, result); - } - return result; - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, T recipe) { - BASE_SERIALIZER.toNetwork(buffer, recipe.getBaseRecipe()); - if (this.writeBuffer != null) { - this.writeBuffer.accept(buffer, recipe); - } - } - } -} diff --git a/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipeBuilder.java b/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipeBuilder.java deleted file mode 100644 index 2b693b6..0000000 --- a/src/main/java/dev/micle/totemofreviving/item/crafting/ExtendedShapedRecipeBuilder.java +++ /dev/null @@ -1,185 +0,0 @@ -package dev.micle.totemofreviving.item.crafting; - -import com.google.common.collect.Sets; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import net.minecraft.advancements.Advancement; -import net.minecraft.advancements.AdvancementRewards; -import net.minecraft.advancements.CriterionTriggerInstance; -import net.minecraft.advancements.RequirementsStrategy; -import net.minecraft.advancements.critereon.EntityPredicate; -import net.minecraft.advancements.critereon.RecipeUnlockedTrigger; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.level.ItemLike; -import net.minecraftforge.registries.ForgeRegistries; - -import javax.annotation.Nullable; -import java.util.*; -import java.util.function.Consumer; - -public class ExtendedShapedRecipeBuilder { - private final RecipeSerializer serializer; - private final Item result; - private final int count; - private final List pattern = new ArrayList<>(); - private final Map key = new LinkedHashMap<>(); - private final Advancement.Builder advancementBuilder = Advancement.Builder.advancement(); - private boolean hasAdvancementCriterion = false; - private String group = ""; - - private ExtendedShapedRecipeBuilder(RecipeSerializer serializer, ItemLike result, int count) { - this.serializer = serializer; - this.result = result.asItem(); - this.count = count; - } - - public static ExtendedShapedRecipeBuilder shaped(RecipeSerializer serializer, ItemLike result) { - return shaped(serializer, result, 1); - } - - public static ExtendedShapedRecipeBuilder shaped(RecipeSerializer serializer, ItemLike result, int count) { - return new ExtendedShapedRecipeBuilder(serializer, result, count); - } - - public ExtendedShapedRecipeBuilder define(Character symbol, TagKey tagIn) { - return this.define(symbol, Ingredient.of(tagIn)); - } - - public ExtendedShapedRecipeBuilder define(Character symbol, ItemLike itemIn) { - return this.define(symbol, Ingredient.of(itemIn)); - } - - public ExtendedShapedRecipeBuilder define(Character symbol, Ingredient ingredientIn) { - if (this.key.containsKey(symbol)) { - throw new IllegalArgumentException("Symbol '" + symbol + "' is already defined!"); - } else if (symbol == ' ') { - throw new IllegalArgumentException("Symbol ' ' (whitespace) is reserved and cannot be defined"); - } else { - this.key.put(symbol, ingredientIn); - return this; - } - } - - public ExtendedShapedRecipeBuilder pattern(String patternIn) { - if (!this.pattern.isEmpty() && patternIn.length() != this.pattern.get(0).length()) { - throw new IllegalArgumentException("Pattern must be the same width on every line!"); - } else { - this.pattern.add(patternIn); - return this; - } - } - - public ExtendedShapedRecipeBuilder unlockedBy(String name, CriterionTriggerInstance criterionIn) { - this.advancementBuilder.addCriterion(name, criterionIn); - this.hasAdvancementCriterion = true; - return this; - } - - public ExtendedShapedRecipeBuilder group(String groupIn) { - this.group = groupIn; - return this; - } - - public void save(Consumer consumer) { - save(consumer, ForgeRegistries.ITEMS.getKey(this.result.asItem())); - } - - public void save(Consumer consumer, ResourceLocation id) { - this.validate(id); - if (this.hasAdvancementCriterion && !this.advancementBuilder.getCriteria().isEmpty()) { - this.advancementBuilder.parent(new ResourceLocation("recipes/root")) - .addCriterion("has_the_recipe", new RecipeUnlockedTrigger.TriggerInstance(EntityPredicate.Composite.ANY, id)) - .rewards(AdvancementRewards.Builder.recipe(id)) - .requirements(RequirementsStrategy.OR); - } - ResourceLocation advancementId = new ResourceLocation(id.getNamespace(), "recipes/" + this.result.getItemCategory().getRecipeFolderName() + "/" + id.getPath()); - consumer.accept(new Result(id, this, advancementId)); - } - - private void validate(ResourceLocation id) { - if (this.pattern.isEmpty()) { - throw new IllegalStateException("No pattern is defined for shaped recipe " + id + "!"); - } else { - Set set = Sets.newHashSet(this.key.keySet()); - set.remove(' '); - - for (String s : this.pattern) { - for (int i = 0; i < s.length(); ++i) { - char c0 = s.charAt(i); - if (!this.key.containsKey(c0) && c0 != ' ') { - throw new IllegalStateException("Pattern in recipe " + id + " uses undefined symbol '" + c0 + "'"); - } - - set.remove(c0); - } - } - - if (!set.isEmpty()) { - throw new IllegalStateException("Ingredients are defined but not used in pattern for recipe " + id); - } else if (this.pattern.size() == 1 && this.pattern.get(0).length() == 1) { - throw new IllegalStateException("Shaped recipe " + id + " only takes in a single item - should it be a shapeless recipe instead?"); - } - } - } - - public static class Result implements FinishedRecipe { - private final ResourceLocation id; - private final ExtendedShapedRecipeBuilder builder; - private final ResourceLocation advancementId; - - public Result(ResourceLocation id, ExtendedShapedRecipeBuilder builder, ResourceLocation advancementId) { - this.id = id; - this.builder = builder; - this.advancementId = advancementId; - } - - @Override - public void serializeRecipeData(JsonObject json) { - if (!builder.group.isEmpty()) { - json.addProperty("group", builder.group); - } - - JsonArray pattern = new JsonArray(); - builder.pattern.forEach(pattern::add); - json.add("pattern", pattern); - - JsonObject key = new JsonObject(); - builder.key.forEach((c, ingredient) -> key.add(String.valueOf(c), ingredient.toJson())); - json.add("key", key); - - JsonObject result = new JsonObject(); - result.addProperty("item", ForgeRegistries.ITEMS.getKey(builder.result.asItem()).toString()); - if (builder.count > 1) { - result.addProperty("count", builder.count); - } - json.add("result", result); - } - - @Override - public RecipeSerializer getType() { - return builder.serializer; - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return builder.hasAdvancementCriterion ? builder.advancementBuilder.serializeToJson() : null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return builder.hasAdvancementCriterion ? advancementId : null; - } - } -} diff --git a/src/main/java/dev/micle/totemofreviving/item/crafting/TotemRecipe.java b/src/main/java/dev/micle/totemofreviving/item/crafting/TotemRecipe.java deleted file mode 100644 index d613313..0000000 --- a/src/main/java/dev/micle/totemofreviving/item/crafting/TotemRecipe.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.micle.totemofreviving.item.crafting; - -import dev.micle.totemofreviving.item.totem.TotemItem; -import dev.micle.totemofreviving.setup.ModRecipes; -import net.minecraft.world.inventory.CraftingContainer; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.ShapedRecipe; -import net.minecraft.world.level.Level; - -public class TotemRecipe extends ExtendedShapedRecipe { - public TotemRecipe(ShapedRecipe recipe) { - super(recipe); - } - - @Override - public RecipeSerializer getSerializer() { - return ModRecipes.TOTEM_RECIPE.get(); - } - - @Override - public boolean matches(CraftingContainer inventory, Level world) { - if (!TotemItem.isEnabled(getResultItem())) { - return false; - } - return getBaseRecipe().matches(inventory, world); - } - - @Override - public ItemStack assemble(CraftingContainer inventory) { - return getBaseRecipe().getResultItem().copy(); - } -} diff --git a/src/main/java/dev/micle/totemofreviving/item/totem/DiamondTotemItem.java b/src/main/java/dev/micle/totemofreviving/item/totem/DiamondTotemItem.java index e77e299..9e33a7e 100644 --- a/src/main/java/dev/micle/totemofreviving/item/totem/DiamondTotemItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/totem/DiamondTotemItem.java @@ -1,7 +1,7 @@ package dev.micle.totemofreviving.item.totem; -import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.item.charge.DiamondChargeItem; +import dev.micle.totemofreviving.setup.Config; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; diff --git a/src/main/java/dev/micle/totemofreviving/item/totem/IronTotemItem.java b/src/main/java/dev/micle/totemofreviving/item/totem/IronTotemItem.java index 5487a86..1e574aa 100644 --- a/src/main/java/dev/micle/totemofreviving/item/totem/IronTotemItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/totem/IronTotemItem.java @@ -1,7 +1,7 @@ package dev.micle.totemofreviving.item.totem; -import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.item.charge.IronChargeItem; +import dev.micle.totemofreviving.setup.Config; import net.minecraft.world.item.ItemStack; public class IronTotemItem extends TotemItem { diff --git a/src/main/java/dev/micle/totemofreviving/item/totem/NetheriteTotemItem.java b/src/main/java/dev/micle/totemofreviving/item/totem/NetheriteTotemItem.java index c904156..f538324 100644 --- a/src/main/java/dev/micle/totemofreviving/item/totem/NetheriteTotemItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/totem/NetheriteTotemItem.java @@ -1,7 +1,7 @@ package dev.micle.totemofreviving.item.totem; -import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.item.charge.NetheriteChargeItem; +import dev.micle.totemofreviving.setup.Config; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; diff --git a/src/main/java/dev/micle/totemofreviving/item/totem/StrawTotemItem.java b/src/main/java/dev/micle/totemofreviving/item/totem/StrawTotemItem.java index a03eb24..c731c54 100644 --- a/src/main/java/dev/micle/totemofreviving/item/totem/StrawTotemItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/totem/StrawTotemItem.java @@ -1,7 +1,7 @@ package dev.micle.totemofreviving.item.totem; -import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.item.charge.StrawChargeItem; +import dev.micle.totemofreviving.setup.Config; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; diff --git a/src/main/java/dev/micle/totemofreviving/item/totem/TotemItem.java b/src/main/java/dev/micle/totemofreviving/item/totem/TotemItem.java index ff928df..12d628e 100644 --- a/src/main/java/dev/micle/totemofreviving/item/totem/TotemItem.java +++ b/src/main/java/dev/micle/totemofreviving/item/totem/TotemItem.java @@ -1,11 +1,10 @@ package dev.micle.totemofreviving.item.totem; -import dev.micle.totemofreviving.TotemOfReviving; -import dev.micle.totemofreviving.setup.Config; +import dev.micle.totemofreviving.network.NetworkManager; import dev.micle.totemofreviving.network.client.ChangeTargetPacket; import dev.micle.totemofreviving.network.client.ChargeTotemPacket; -import dev.micle.totemofreviving.network.NetworkManager; import dev.micle.totemofreviving.network.client.ReviveTargetPacket; +import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.setup.ModKeyMappings; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -39,9 +38,9 @@ public abstract class TotemItem extends Item { } public TotemItem(Rarity rarity, int durability) { - super(new Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(1).rarity(rarity).defaultDurability(durability)); + super(new Properties().stacksTo(1).rarity(rarity).defaultDurability(durability)); } - + public abstract boolean isCharge(ItemStack stack); public static int getTargetIndex(ItemStack stack) { @@ -146,11 +145,6 @@ public abstract class TotemItem extends Item { return getConfig(stack).getCanReviveMoreExpensiveTargets(); } - public static boolean isEnabled(ItemStack stack) { - if (!isTotem(stack)) { return false; } - return getConfig(stack).getIsEnabled(); - } - @Override @OnlyIn(Dist.CLIENT) @ParametersAreNonnullByDefault @@ -163,41 +157,37 @@ public abstract class TotemItem extends Item { int charge = getCharge(stack); int maxCharge = getMaxCharge(stack); double multiplier = getConfig(stack).getChargeCostMultiplier(); - - if (getConfig(stack).getIsEnabled()) { - if (targetUUID == null) { - tooltip.add(Component.literal(ChatFormatting.RED + "Target: " + ChatFormatting.DARK_RED + "NONE")); - } else { - tooltip.add(Component.literal(ChatFormatting.WHITE + "Target: " + ChatFormatting.GRAY + targetName)); - } - tooltip.add(Component.literal("")); - if (!canTotemAffordTarget(stack)) { - tooltip.add(Component.literal(ChatFormatting.RED + "Charges: " + ChatFormatting.DARK_RED + "(" + charge + "/" + targetCost + ") " + - ChatFormatting.RED + "[Max: " + ChatFormatting.DARK_RED + maxCharge + ChatFormatting.RED + "] [Multi: " + ChatFormatting.DARK_RED + multiplier + ChatFormatting.RED + "]")); - } else { - tooltip.add(Component.literal(ChatFormatting.WHITE + "Charges: " + ChatFormatting.GRAY + "(" + charge + "/" + targetCost + ") " + - ChatFormatting.WHITE + "[Max: " + ChatFormatting.GRAY + maxCharge + ChatFormatting.WHITE + "] [Multi: " + ChatFormatting.GRAY + multiplier + ChatFormatting.WHITE + "]")); - } - if (canReviveMoreExpensiveTargets(stack)) { - tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive more expensive targets.")); - } - if (canReviveAcrossDimensions(stack)) { - tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive targets across dimensions.")); - } - tooltip.add(Component.literal("")); - if (ModKeyMappings.ADVANCED_TOOLTIP.isDown()) { - tooltip.add(Component.literal(ChatFormatting.GRAY + "Showing advanced tooltip.")); - tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "R-CLICK" + ChatFormatting.WHITE + "]")); - tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is empty: revive target.")); - tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is holding a reviving charge: charge totem.")); - tooltip.add(Component.literal("")); - tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "L-SHIFT + R-CLICK" + ChatFormatting.WHITE + "]")); - tooltip.add(Component.literal(ChatFormatting.WHITE + "Change target.")); - } else { - tooltip.add(Component.literal(ChatFormatting.GRAY + "Hold [" + ChatFormatting.DARK_GRAY + "L-SHIFT" + ChatFormatting.GRAY + "] for advanced tooltip.")); - } + + if (targetUUID == null) { + tooltip.add(Component.literal(ChatFormatting.RED + "Target: " + ChatFormatting.DARK_RED + "NONE")); } else { - tooltip.add(Component.literal(ChatFormatting.RED + "Totem is disabled!")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "Target: " + ChatFormatting.GRAY + targetName)); + } + tooltip.add(Component.literal("")); + if (!canTotemAffordTarget(stack)) { + tooltip.add(Component.literal(ChatFormatting.RED + "Charges: " + ChatFormatting.DARK_RED + "(" + charge + "/" + targetCost + ") " + + ChatFormatting.RED + "[Max: " + ChatFormatting.DARK_RED + maxCharge + ChatFormatting.RED + "] [Multi: " + ChatFormatting.DARK_RED + multiplier + ChatFormatting.RED + "]")); + } else { + tooltip.add(Component.literal(ChatFormatting.WHITE + "Charges: " + ChatFormatting.GRAY + "(" + charge + "/" + targetCost + ") " + + ChatFormatting.WHITE + "[Max: " + ChatFormatting.GRAY + maxCharge + ChatFormatting.WHITE + "] [Multi: " + ChatFormatting.GRAY + multiplier + ChatFormatting.WHITE + "]")); + } + if (canReviveMoreExpensiveTargets(stack)) { + tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive more expensive targets.")); + } + if (canReviveAcrossDimensions(stack)) { + tooltip.add(Component.literal(ChatFormatting.WHITE + "Can revive targets across dimensions.")); + } + tooltip.add(Component.literal("")); + if (ModKeyMappings.ADVANCED_TOOLTIP.isDown()) { + tooltip.add(Component.literal(ChatFormatting.GRAY + "Showing advanced tooltip.")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "R-CLICK" + ChatFormatting.WHITE + "]")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is empty: revive target.")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "When second hand is holding a reviving charge: charge totem.")); + tooltip.add(Component.literal("")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "[" + ChatFormatting.GRAY + "L-SHIFT + R-CLICK" + ChatFormatting.WHITE + "]")); + tooltip.add(Component.literal(ChatFormatting.WHITE + "Change target.")); + } else { + tooltip.add(Component.literal(ChatFormatting.GRAY + "Hold [" + ChatFormatting.DARK_GRAY + "L-SHIFT" + ChatFormatting.GRAY + "] for advanced tooltip.")); } super.appendHoverText(stack, world, tooltip, tooltipFlag); } @@ -206,7 +196,7 @@ public abstract class TotemItem extends Item { @OnlyIn(Dist.CLIENT) @ParametersAreNonnullByDefault public InteractionResultHolder use(Level world, Player player, InteractionHand hand) { - if (!getConfig(player.getItemInHand(hand)).getIsEnabled() || !world.isClientSide) { + if (!world.isClientSide) { return super.use(world, player, hand); } diff --git a/src/main/java/dev/micle/totemofreviving/network/client/ChangeTargetPacket.java b/src/main/java/dev/micle/totemofreviving/network/client/ChangeTargetPacket.java index 4785e9d..1651d68 100644 --- a/src/main/java/dev/micle/totemofreviving/network/client/ChangeTargetPacket.java +++ b/src/main/java/dev/micle/totemofreviving/network/client/ChangeTargetPacket.java @@ -2,14 +2,9 @@ package dev.micle.totemofreviving.network.client; import dev.micle.totemofreviving.TotemOfReviving; import dev.micle.totemofreviving.item.totem.TotemItem; -import dev.micle.totemofreviving.network.NetworkManager; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.OutgoingPlayerChatMessage; -import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; import net.minecraft.world.InteractionHand; diff --git a/src/main/java/dev/micle/totemofreviving/network/client/ChargeTotemPacket.java b/src/main/java/dev/micle/totemofreviving/network/client/ChargeTotemPacket.java index 3879f2f..6abb968 100644 --- a/src/main/java/dev/micle/totemofreviving/network/client/ChargeTotemPacket.java +++ b/src/main/java/dev/micle/totemofreviving/network/client/ChargeTotemPacket.java @@ -1,7 +1,6 @@ package dev.micle.totemofreviving.network.client; import dev.micle.totemofreviving.item.totem.TotemItem; -import dev.micle.totemofreviving.network.NetworkManager; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; diff --git a/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java b/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java index 2c4cb9d..0c29e72 100644 --- a/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java +++ b/src/main/java/dev/micle/totemofreviving/proxy/Proxy.java @@ -1,8 +1,7 @@ package dev.micle.totemofreviving.proxy; -import dev.micle.totemofreviving.setup.Config; -import dev.micle.totemofreviving.data.DataGenerators; import dev.micle.totemofreviving.network.NetworkManager; +import dev.micle.totemofreviving.setup.Config; import dev.micle.totemofreviving.setup.Registration; import net.minecraft.client.Minecraft; import net.minecraft.server.MinecraftServer; @@ -31,7 +30,6 @@ public class Proxy implements IProxy { // Register mod event bus listeners IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - modEventBus.addListener(DataGenerators::gatherData); modEventBus.addListener(Proxy::setup); modEventBus.addListener(Proxy::imcEnqueue); modEventBus.addListener(Proxy::imcProcess); diff --git a/src/main/java/dev/micle/totemofreviving/setup/Config.java b/src/main/java/dev/micle/totemofreviving/setup/Config.java index b18df1c..9be35c4 100644 --- a/src/main/java/dev/micle/totemofreviving/setup/Config.java +++ b/src/main/java/dev/micle/totemofreviving/setup/Config.java @@ -26,13 +26,13 @@ public final class Config { builder.comment("WHEN MAKING CHANGES IT IS RECOMMENDED TO NOT BE IN A WORLD.\n" + "CHANGES WILL MOST LIKELY REQUIRE A RESTART FOR EVERYTHING TO WORK PROPERLY."); - STRAW_TOTEM_CONFIG = new TotemConfig(builder, StrawTotemItem.getName(), true, -1, 3, + STRAW_TOTEM_CONFIG = new TotemConfig(builder, StrawTotemItem.getName(), -1, 3, 1, false, false, 1); - IRON_TOTEM_CONFIG = new TotemConfig(builder, IronTotemItem.getName(), true, -1, 5, + IRON_TOTEM_CONFIG = new TotemConfig(builder, IronTotemItem.getName(), -1, 5, 0.75, false, false, 4); - DIAMOND_TOTEM_CONFIG = new TotemConfig(builder, DiamondTotemItem.getName(), true, -1, 10, + DIAMOND_TOTEM_CONFIG = new TotemConfig(builder, DiamondTotemItem.getName(), -1, 10, 0.5, false, false, 10); - NETHERITE_TOTEM_CONFIG = new TotemConfig(builder, NetheriteTotemItem.getName(), true, 1, 1, + NETHERITE_TOTEM_CONFIG = new TotemConfig(builder, NetheriteTotemItem.getName(), 1, 1, 1, true, true, 0); SPEC = builder.build(); @@ -45,7 +45,6 @@ public final class Config { } public static class TotemConfig { - private final ForgeConfigSpec.BooleanValue IS_ENABLED; private final ForgeConfigSpec.IntValue CHARGE_COST; private final ForgeConfigSpec.IntValue CHARGE_COST_LIMIT; private final ForgeConfigSpec.DoubleValue CHARGE_COST_MULTIPLIER; @@ -53,13 +52,10 @@ public final class Config { private final ForgeConfigSpec.BooleanValue CAN_REVIVE_ACROSS_DIMENSIONS; private final ForgeConfigSpec.IntValue DURABILITY; - public TotemConfig(ForgeConfigSpec.Builder builder, String name, boolean isEnabled, int chargeCost, + public TotemConfig(ForgeConfigSpec.Builder builder, String name, int chargeCost, int chargeCostLimit, double chargeCostMultiplier, boolean canReviveMoreExpensiveTargets, boolean canReviveAcrossDimensions, int durability) { builder.push(name); - IS_ENABLED = builder - .comment("Is the " + name + " enabled?") - .define("isEnabled", isEnabled); CHARGE_COST = builder .comment("The charge cost to revive a player.\n" + "-1 means the cost is dynamic (follows the amount of deaths the target has)\n" + @@ -83,8 +79,7 @@ public final class Config { .defineInRange("durability", durability, 0, Integer.MAX_VALUE); builder.pop(); } - - public boolean getIsEnabled() { return IS_ENABLED.get(); } + public int getChargeCost() { return CHARGE_COST.get(); } public int getChargeCostLimit() { return CHARGE_COST_LIMIT.get(); } public double getChargeCostMultiplier() { return CHARGE_COST_MULTIPLIER.get(); } diff --git a/src/main/java/dev/micle/totemofreviving/setup/ModRecipes.java b/src/main/java/dev/micle/totemofreviving/setup/ModRecipes.java deleted file mode 100644 index 5d15d26..0000000 --- a/src/main/java/dev/micle/totemofreviving/setup/ModRecipes.java +++ /dev/null @@ -1,16 +0,0 @@ -package dev.micle.totemofreviving.setup; - -import dev.micle.totemofreviving.item.crafting.ChargeRecipe; -import dev.micle.totemofreviving.item.crafting.ExtendedShapedRecipe; -import dev.micle.totemofreviving.item.crafting.TotemRecipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraftforge.registries.RegistryObject; - -public class ModRecipes { - public static final RegistryObject> TOTEM_RECIPE = - Registration.RECIPE_SERIALIZERS.register("totem_recipe", () -> ExtendedShapedRecipe.Serializer.basic(TotemRecipe::new)); - public static final RegistryObject> CHARGE_RECIPE = - Registration.RECIPE_SERIALIZERS.register("charge_recipe", () -> ExtendedShapedRecipe.Serializer.basic(ChargeRecipe::new)); - - public static void register() {} -} diff --git a/src/main/java/dev/micle/totemofreviving/setup/Registration.java b/src/main/java/dev/micle/totemofreviving/setup/Registration.java index 40f41c1..3dcd1c3 100644 --- a/src/main/java/dev/micle/totemofreviving/setup/Registration.java +++ b/src/main/java/dev/micle/totemofreviving/setup/Registration.java @@ -1,8 +1,8 @@ package dev.micle.totemofreviving.setup; import dev.micle.totemofreviving.TotemOfReviving; +import dev.micle.totemofreviving.event.common.OnCreativeModeTabRegisterEventHandler; import net.minecraft.world.item.Item; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -12,16 +12,13 @@ public class Registration { // Initialize variables public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TotemOfReviving.MOD_ID); - public static final DeferredRegister> RECIPE_SERIALIZERS = - DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, TotemOfReviving.MOD_ID); public static void register() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - + ITEMS.register(modEventBus); ModItems.register(); - - RECIPE_SERIALIZERS.register(modEventBus); - ModRecipes.register(); + + modEventBus.register(OnCreativeModeTabRegisterEventHandler.class); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index e00e6ba..45d11de 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader = "javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion = "[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion = "[45,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license = "All Rights Reserved" @@ -43,7 +43,7 @@ Mod for reviving players in a hardcore world. # Does this dependency have to exist - if not, ordering below must be specified mandatory = true #mandatory # The version range of the dependency - versionRange = "[43,)" #mandatory + versionRange = "[45,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering = "NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -53,6 +53,6 @@ Mod for reviving players in a hardcore world. modId = "minecraft" mandatory = true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange = "[1.19.2,1.20)" + versionRange = "[1.19.4,1.20)" ordering = "NONE" side = "BOTH" diff --git a/src/main/resources/assets/totemofreviving/lang/en_us.json b/src/main/resources/assets/totemofreviving/lang/en_us.json index 755693e..6ffda43 100644 --- a/src/main/resources/assets/totemofreviving/lang/en_us.json +++ b/src/main/resources/assets/totemofreviving/lang/en_us.json @@ -1,5 +1,5 @@ { - "itemGroup.totemofreviving": "Micle's Totem of Reviving", + "tabs.totemofreviving.main_tab": "Micle's Totem of Reviving", "item.totemofreviving.straw_totem": "Straw totem of reviving", "item.totemofreviving.iron_totem": "Iron totem of reviving", "item.totemofreviving.diamond_totem": "Diamond totem of reviving",