From fca657090ba57182b2a33711ed1487cf78e9a812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E9=9B=A8=E8=90=BD?= Date: Tue, 20 Feb 2024 23:38:04 +0800 Subject: [PATCH] WIP: maybe compiles now. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 秋雨落 --- build.gradle | 5 +-- catsplus-fabric/build.gradle | 8 ++--- .../catsplus/fabric/CatsPlusFabric.java | 16 +++------- .../fabric/data/lang/ModLangProviderENUS.java | 2 +- .../fabric/data/lang/ModLangProviderZHCN.java | 2 +- .../fabric/registry/BlockRegistry.java | 17 ---------- .../fabric/registry/EffectRegistry.java | 17 ---------- .../fabric/registry/ItemGroupRegistry.java | 17 ---------- .../fabric/registry/ItemRegistry.java | 23 ------------- .../fabric/registry/PotionRegistry.java | 32 ------------------- src/main/java/cuteneko/catsplus/CatsPlus.java | 13 ++++++++ .../cuteneko/catsplus/block/ModBlocks.java | 18 +++++++++-- .../cuteneko/catsplus/effect/ModEffects.java | 12 +++++-- .../catsplus/effect/potion/ModPotions.java | 15 ++++++--- .../cuteneko/catsplus/item/CatBagItem.java | 10 ++++-- .../cuteneko/catsplus/item/CatSpiritItem.java | 8 +++-- .../cuteneko/catsplus/item/FangLuoItem.java | 8 +++-- .../java/cuteneko/catsplus/item/ModItems.java | 24 +++++++------- .../catsplus/item/group/ModItemGroups.java | 22 ++++++------- 19 files changed, 103 insertions(+), 166 deletions(-) delete mode 100644 catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/BlockRegistry.java delete mode 100644 catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/EffectRegistry.java delete mode 100644 catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemGroupRegistry.java delete mode 100644 catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemRegistry.java delete mode 100644 catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/PotionRegistry.java diff --git a/build.gradle b/build.gradle index 17c9bb5..8e6b881 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,8 @@ allprojects { dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + + modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" modApi "dev.architectury:architectury:${project.architectury_version}" } @@ -51,7 +53,6 @@ allprojects { if (JavaVersion.current() < javaVersion) { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } - archivesBaseName = project.archives_base_name withSourcesJar() } @@ -94,7 +95,7 @@ architectury { } loom { - accessWidenerPath = file("src/main/resources/catsplus.accesswidener") + accessWidenerPath = file('src/main/resources/catsplus.accesswidener') } sourceSets.main.resources.srcDir 'src/main/generated' diff --git a/catsplus-fabric/build.gradle b/catsplus-fabric/build.gradle index 87aad29..ccf7015 100644 --- a/catsplus-fabric/build.gradle +++ b/catsplus-fabric/build.gradle @@ -15,13 +15,13 @@ loom { data { inherit client - name "Data Generation" + name 'Data Generation' - vmArg "-Dfabric-api.datagen" + vmArg '-Dfabric-api.datagen' vmArg "-Dfabric-api.datagen.output-dir=${file("../src/main/generated")}" - vmArg "-Dfabric-api.datagen.modid=${project.mod_id}" + vmArg '-Dfabric-api.datagen.modid=catsplus' - runDir "build/datagen" + runDir 'build/datagen' } } } diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/CatsPlusFabric.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/CatsPlusFabric.java index 73f80ef..0eea1da 100644 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/CatsPlusFabric.java +++ b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/CatsPlusFabric.java @@ -2,24 +2,18 @@ import cuteneko.catsplus.CatsPlus; import cuteneko.catsplus.fabric.platform.CatsPlusFabricPlatform; -import cuteneko.catsplus.fabric.registry.PotionRegistry; -import cuteneko.catsplus.fabric.registry.BlockRegistry; -import cuteneko.catsplus.fabric.registry.EffectRegistry; -import cuteneko.catsplus.fabric.registry.ItemGroupRegistry; -import cuteneko.catsplus.fabric.registry.ItemRegistry; import net.fabricmc.api.ModInitializer; public class CatsPlusFabric implements ModInitializer { + private final CatsPlus mod; + public CatsPlusFabric() { - new CatsPlus().setPlatform(new CatsPlusFabricPlatform()); + mod = new CatsPlus(); + mod.setPlatform(new CatsPlusFabricPlatform()); } @Override public void onInitialize() { - ItemRegistry.register(); - ItemGroupRegistry.register(); - EffectRegistry.register(); - PotionRegistry.register(); - BlockRegistry.register(); + mod.init(); } } diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderENUS.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderENUS.java index 2519c0d..887e3ec 100644 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderENUS.java +++ b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderENUS.java @@ -20,7 +20,7 @@ public void generateTranslations(TranslationBuilder builder) { builder.add(ModItems.FANG_LUO, "Paper Model of Fang_Luo"); builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION, "Don't be sad, have a hug..."); // Don't change to other language when translating. - builder.add(ModBlocks.CAT_RESURRECTION_STATION, "Cat Resurrection Station"); + builder.add(ModBlocks.CAT_RESURRECTION_STATION_BLOCK, "Cat Resurrection Station"); builder.add(ModEffects.CATTIFY, "Cattify"); builder.add(Constants.MESSAGE_CATTIFY_POTION, "Potion of Cattify"); diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderZHCN.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderZHCN.java index b5f7b90..a9ad309 100644 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderZHCN.java +++ b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/data/lang/ModLangProviderZHCN.java @@ -20,7 +20,7 @@ public void generateTranslations(TranslationBuilder builder) { builder.add(ModItems.FANG_LUO, "坊洛纸模"); builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION, "Don't be sad, have a hug..."); - builder.add(ModBlocks.CAT_RESURRECTION_STATION, "猫咪复活台"); + builder.add(ModBlocks.CAT_RESURRECTION_STATION_BLOCK, "猫咪复活台"); builder.add(ModEffects.CATTIFY, "猫咪化"); builder.add(Constants.MESSAGE_CATTIFY_POTION, "变猫药水"); diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/BlockRegistry.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/BlockRegistry.java deleted file mode 100644 index 580848b..0000000 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/BlockRegistry.java +++ /dev/null @@ -1,17 +0,0 @@ -package cuteneko.catsplus.fabric.registry; - -import cuteneko.catsplus.block.ModBlocks; -import net.minecraft.block.Block; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; - -public class BlockRegistry { - private static void register(Identifier identifier, Block block) { - Registry.register(Registries.BLOCK, identifier, block); - } - - public static void register() { - register(ModBlocks.ID_CAT_RESURRECTION_STATION, ModBlocks.CAT_RESURRECTION_STATION); - } -} diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/EffectRegistry.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/EffectRegistry.java deleted file mode 100644 index e02e595..0000000 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/EffectRegistry.java +++ /dev/null @@ -1,17 +0,0 @@ -package cuteneko.catsplus.fabric.registry; - -import cuteneko.catsplus.effect.ModEffects; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; - -public class EffectRegistry { - private static void register(Identifier identifier, StatusEffect effect) { - Registry.register(Registries.STATUS_EFFECT, identifier, effect); - } - - public static void register() { - register(ModEffects.ID_CATTIFY, ModEffects.CATTIFY); - } -} diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemGroupRegistry.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemGroupRegistry.java deleted file mode 100644 index e5377d5..0000000 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemGroupRegistry.java +++ /dev/null @@ -1,17 +0,0 @@ -package cuteneko.catsplus.fabric.registry; - -import cuteneko.catsplus.item.ModItems; -import cuteneko.catsplus.item.group.ModItemGroups; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.minecraft.item.ItemGroups; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; - -public class ItemGroupRegistry { - public static void register() { - Registry.register(Registries.ITEM_GROUP, ModItemGroups.ID_CATS_PLUS_GROUP, ModItemGroups.buildCatsPlusGroup(FabricItemGroup.builder())); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(content -> content.add(ModItems.CAT_BAG)); - } -} diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemRegistry.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemRegistry.java deleted file mode 100644 index 3606d43..0000000 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/ItemRegistry.java +++ /dev/null @@ -1,23 +0,0 @@ -package cuteneko.catsplus.fabric.registry; - -import cuteneko.catsplus.block.ModBlocks; -import cuteneko.catsplus.item.ModItems; -import net.minecraft.item.Item; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; - -public class ItemRegistry { - private static void register(Identifier identifier, Item item) { - Registry.register(Registries.ITEM, identifier, item); - } - - public static void register() { - register(ModItems.ID_CAT_BAG, ModItems.CAT_BAG); - register(ModItems.ID_TOTEMEOW, ModItems.TOTEMEOW); - register(ModItems.ID_CAT_SPIRIT, ModItems.CAT_SPIRIT); - register(ModItems.ID_FANG_LUO, ModItems.FANG_LUO); - - register(ModBlocks.ID_CAT_RESURRECTION_STATION, ModItems.CAT_RESURRECTION_STATION_BLOCK); - } -} diff --git a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/PotionRegistry.java b/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/PotionRegistry.java deleted file mode 100644 index cfbde16..0000000 --- a/catsplus-fabric/src/main/java/cuteneko/catsplus/fabric/registry/PotionRegistry.java +++ /dev/null @@ -1,32 +0,0 @@ -package cuteneko.catsplus.fabric.registry; - -import cuteneko.catsplus.effect.potion.ModPotions; -import net.minecraft.item.Items; -import net.minecraft.potion.Potion; -import net.minecraft.potion.Potions; -import net.minecraft.recipe.BrewingRecipeRegistry; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; - -public class PotionRegistry { - private static Potion register(Identifier identifier, Potion potion) { - return Registry.register(Registries.POTION, identifier, potion); - } - - public static void register() { - PotionRegistry.register(ModPotions.ID_CATTIFY, ModPotions.CATTIFY); - PotionRegistry.register(ModPotions.ID_LONG_CATTIFY, ModPotions.LONG_CATTIFY); - - registerRecipe(); - } - - private static void registerRecipe() { - BrewingRecipeRegistry.registerPotionRecipe(Potions.MUNDANE, Items.COD, ModPotions.CATTIFY); - BrewingRecipeRegistry.registerPotionRecipe(Potions.MUNDANE, Items.SALMON, ModPotions.CATTIFY); - BrewingRecipeRegistry.registerPotionRecipe(Potions.MUNDANE, Items.COOKED_COD, ModPotions.CATTIFY); - BrewingRecipeRegistry.registerPotionRecipe(Potions.MUNDANE, Items.COOKED_SALMON, ModPotions.CATTIFY); - BrewingRecipeRegistry.registerPotionRecipe(Potions.MUNDANE, Items.TROPICAL_FISH, ModPotions.CATTIFY); - BrewingRecipeRegistry.registerPotionRecipe(ModPotions.CATTIFY, Items.REDSTONE, ModPotions.LONG_CATTIFY); - } -} diff --git a/src/main/java/cuteneko/catsplus/CatsPlus.java b/src/main/java/cuteneko/catsplus/CatsPlus.java index c41cc4c..c09a39c 100644 --- a/src/main/java/cuteneko/catsplus/CatsPlus.java +++ b/src/main/java/cuteneko/catsplus/CatsPlus.java @@ -1,5 +1,10 @@ package cuteneko.catsplus; +import cuteneko.catsplus.block.ModBlocks; +import cuteneko.catsplus.effect.ModEffects; +import cuteneko.catsplus.effect.potion.ModPotions; +import cuteneko.catsplus.item.ModItems; +import cuteneko.catsplus.item.group.ModItemGroups; import cuteneko.catsplus.platform.ICatsPlusPlatform; public class CatsPlus { @@ -17,6 +22,14 @@ public static CatsPlus getInstance() { return INSTANCE; } + public void init() { + ModItemGroups.register(); + ModBlocks.register(); + ModItems.register(); + ModEffects.register(); + ModPotions.register(); + } + public void setPlatform(ICatsPlusPlatform platform) { this.platform = platform; } diff --git a/src/main/java/cuteneko/catsplus/block/ModBlocks.java b/src/main/java/cuteneko/catsplus/block/ModBlocks.java index 763bd5c..1bb00ae 100644 --- a/src/main/java/cuteneko/catsplus/block/ModBlocks.java +++ b/src/main/java/cuteneko/catsplus/block/ModBlocks.java @@ -1,12 +1,24 @@ package cuteneko.catsplus.block; import cuteneko.catsplus.CatsPlus; +import cuteneko.catsplus.item.group.ModItemGroups; +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; -import net.minecraft.util.Identifier; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.registry.RegistryKeys; public class ModBlocks { - public static final Identifier ID_CAT_RESURRECTION_STATION = new Identifier(CatsPlus.MODID, "cat_resurrection_station"); + public static final DeferredRegister BLOCKS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.BLOCK); + public static final DeferredRegister BLOCK_ITEMS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.ITEM); - public static Block CAT_RESURRECTION_STATION = new CatResurrectionStationBlock(AbstractBlock.Settings.create().hardness(5f)); + public static void register() { + BLOCKS.register(); + BLOCK_ITEMS.register(); + } + + public static final RegistrySupplier CAT_RESURRECTION_STATION_BLOCK = BLOCKS.register("cat_resurrection_station", () -> new CatResurrectionStationBlock(AbstractBlock.Settings.create().hardness(5f))); + public static final RegistrySupplier CAT_RESURRECTION_STATION = BLOCK_ITEMS.register("cat_resurrection_station", () -> new BlockItem(CAT_RESURRECTION_STATION_BLOCK.get(), new Item.Settings().arch$tab(ModItemGroups.CATS_PLUS))); } diff --git a/src/main/java/cuteneko/catsplus/effect/ModEffects.java b/src/main/java/cuteneko/catsplus/effect/ModEffects.java index 4d01771..7c6ea7b 100644 --- a/src/main/java/cuteneko/catsplus/effect/ModEffects.java +++ b/src/main/java/cuteneko/catsplus/effect/ModEffects.java @@ -1,11 +1,17 @@ package cuteneko.catsplus.effect; import cuteneko.catsplus.CatsPlus; +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.util.Identifier; +import net.minecraft.registry.RegistryKeys; public class ModEffects { - public static final Identifier ID_CATTIFY = new Identifier(CatsPlus.MODID, "cattify"); + public static final DeferredRegister EFFECTS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.STATUS_EFFECT); - public static final StatusEffect CATTIFY = new CattifyEffect(); + public static void register() { + EFFECTS.register(); + } + + public static final RegistrySupplier CATTIFY = EFFECTS.register("cattify", CattifyEffect::new); } diff --git a/src/main/java/cuteneko/catsplus/effect/potion/ModPotions.java b/src/main/java/cuteneko/catsplus/effect/potion/ModPotions.java index d8f7836..28de6ae 100644 --- a/src/main/java/cuteneko/catsplus/effect/potion/ModPotions.java +++ b/src/main/java/cuteneko/catsplus/effect/potion/ModPotions.java @@ -2,14 +2,19 @@ import cuteneko.catsplus.CatsPlus; import cuteneko.catsplus.effect.ModEffects; +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.potion.Potion; -import net.minecraft.util.Identifier; +import net.minecraft.registry.RegistryKeys; public class ModPotions { - public static final Identifier ID_CATTIFY = new Identifier(CatsPlus.MODID, "cattify"); - public static final Identifier ID_LONG_CATTIFY = new Identifier(CatsPlus.MODID, "long_cattify"); + public static final DeferredRegister POTIONS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.POTION); - public static final Potion CATTIFY = new Potion(new StatusEffectInstance(ModEffects.CATTIFY, 1800)); - public static final Potion LONG_CATTIFY = new Potion(ID_CATTIFY.getPath(), new StatusEffectInstance(ModEffects.CATTIFY, 4800)); + public static void register() { + POTIONS.register(); + } + + public static final RegistrySupplier CATTIFY = POTIONS.register("cattify", () -> new Potion(new StatusEffectInstance(ModEffects.CATTIFY.get(), 1800))); + public static final RegistrySupplier LONG_CATTIFY = POTIONS.register("long_cattify", () -> new Potion("cattify", new StatusEffectInstance(ModEffects.CATTIFY.get(), 4800))); } diff --git a/src/main/java/cuteneko/catsplus/item/CatBagItem.java b/src/main/java/cuteneko/catsplus/item/CatBagItem.java index 48e3b2c..2edbc12 100644 --- a/src/main/java/cuteneko/catsplus/item/CatBagItem.java +++ b/src/main/java/cuteneko/catsplus/item/CatBagItem.java @@ -1,5 +1,6 @@ package cuteneko.catsplus.item; +import cuteneko.catsplus.item.group.ModItemGroups; import cuteneko.catsplus.utility.Constants; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.EntityType; @@ -30,8 +31,11 @@ public class CatBagItem extends Item implements DyeableItem { - public CatBagItem(Settings settings) { - super(settings); + public CatBagItem() { + super(new Item.Settings() + .fireproof() + .maxCount(1) + .arch$tab(ModItemGroups.CATS_PLUS)); } @Override @@ -44,7 +48,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too var cat = stack.getNbt().getCompound(Constants.TAG_CAT_BAG_CAT); if (cat.contains(Constants.TAG_CUSTOM_NAME)) { var name = cat.getString(Constants.TAG_CUSTOM_NAME); - var component = Text.Serializer.fromJson(name); + var component = Text.Serialization.fromJson(name); if (component != null) { tooltip.add(Text.translatable(Constants.MESSAGE_CAT_BAG_HAS_CAT_NAMED, component.getString()).formatted(Formatting.BLUE)); diff --git a/src/main/java/cuteneko/catsplus/item/CatSpiritItem.java b/src/main/java/cuteneko/catsplus/item/CatSpiritItem.java index c1b1ff9..b40a774 100644 --- a/src/main/java/cuteneko/catsplus/item/CatSpiritItem.java +++ b/src/main/java/cuteneko/catsplus/item/CatSpiritItem.java @@ -1,9 +1,13 @@ package cuteneko.catsplus.item; import net.minecraft.item.Item; +import net.minecraft.util.Rarity; public class CatSpiritItem extends Item { - public CatSpiritItem(Settings settings) { - super(settings); + public CatSpiritItem() { + super(new Item.Settings() + .maxCount(1) + .fireproof() + .rarity(Rarity.EPIC)); } } diff --git a/src/main/java/cuteneko/catsplus/item/FangLuoItem.java b/src/main/java/cuteneko/catsplus/item/FangLuoItem.java index e991666..2bcf34e 100644 --- a/src/main/java/cuteneko/catsplus/item/FangLuoItem.java +++ b/src/main/java/cuteneko/catsplus/item/FangLuoItem.java @@ -6,14 +6,18 @@ import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.Rarity; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import java.util.List; public class FangLuoItem extends Item { - public FangLuoItem(Settings settings) { - super(settings); + public FangLuoItem() { + super(new Item.Settings() + .maxCount(1) + .fireproof() + .rarity(Rarity.EPIC)); } @Override diff --git a/src/main/java/cuteneko/catsplus/item/ModItems.java b/src/main/java/cuteneko/catsplus/item/ModItems.java index 01fb1d8..2820f1d 100644 --- a/src/main/java/cuteneko/catsplus/item/ModItems.java +++ b/src/main/java/cuteneko/catsplus/item/ModItems.java @@ -1,22 +1,22 @@ package cuteneko.catsplus.item; import cuteneko.catsplus.CatsPlus; -import cuteneko.catsplus.block.ModBlocks; -import net.minecraft.item.BlockItem; +import cuteneko.catsplus.item.group.ModItemGroups; +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.item.Item; -import net.minecraft.util.Identifier; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Rarity; public class ModItems { - public static final Identifier ID_CAT_BAG = new Identifier(CatsPlus.MODID, "cat_bag"); - public static final Identifier ID_TOTEMEOW = new Identifier(CatsPlus.MODID, "totemeow"); - public static final Identifier ID_CAT_SPIRIT = new Identifier(CatsPlus.MODID, "cat_spirit"); - public static final Identifier ID_FANG_LUO = new Identifier(CatsPlus.MODID, "fang_luo"); + public static final DeferredRegister ITEMS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.ITEM); - public static final Item CAT_BAG = new CatBagItem(new Item.Settings().fireproof().maxCount(1)); - public static final Item TOTEMEOW = new Item(new Item.Settings().maxCount(1).rarity(Rarity.UNCOMMON)); - public static final Item CAT_SPIRIT = new CatSpiritItem(new Item.Settings().maxCount(1).fireproof().rarity(Rarity.EPIC)); - public static final Item FANG_LUO = new FangLuoItem(new Item.Settings().maxCount(1).fireproof().rarity(Rarity.EPIC)); + public static void register() { + ITEMS.register(); + } - public static final Item CAT_RESURRECTION_STATION_BLOCK = new BlockItem(ModBlocks.CAT_RESURRECTION_STATION, new Item.Settings()); + public static final RegistrySupplier CAT_BAG = ITEMS.register("cat_bag", CatBagItem::new); + public static final RegistrySupplier TOTEMEOW = ITEMS.register("totemeow", () -> new Item(new Item.Settings().maxCount(1).rarity(Rarity.UNCOMMON).arch$tab(ModItemGroups.CATS_PLUS))); + public static final RegistrySupplier CAT_SPIRIT = ITEMS.register("cat_spirit", CatSpiritItem::new); + public static final RegistrySupplier FANG_LUO = ITEMS.register("fang_luo", FangLuoItem::new); } diff --git a/src/main/java/cuteneko/catsplus/item/group/ModItemGroups.java b/src/main/java/cuteneko/catsplus/item/group/ModItemGroups.java index 673459d..66e9467 100644 --- a/src/main/java/cuteneko/catsplus/item/group/ModItemGroups.java +++ b/src/main/java/cuteneko/catsplus/item/group/ModItemGroups.java @@ -1,23 +1,23 @@ package cuteneko.catsplus.item.group; +import cuteneko.catsplus.CatsPlus; import cuteneko.catsplus.item.ModItems; import cuteneko.catsplus.utility.Constants; +import dev.architectury.registry.CreativeTabRegistry; +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; +import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; public class ModItemGroups { - public static final Identifier ID_CATS_PLUS_GROUP = new Identifier("catsplus", "catsplus_group"); - public static ItemGroup buildCatsPlusGroup(ItemGroup.Builder builder) { - return builder.displayName(Text.translatable(Constants.MESSAGE_CATS_GROUP_TITLE)) - .icon(() -> new ItemStack(ModItems.CAT_BAG)) - .entries((displayContext, entries) -> { - entries.add(ModItems.CAT_BAG); - entries.add(ModItems.TOTEMEOW); -// entries.add(ModItems.CAT_RESURRECTION_STATION_ITEM); - }) - .build(); + public static final DeferredRegister GROUPS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.ITEM_GROUP); + + public static void register() { + GROUPS.register(); } + + public static final RegistrySupplier CATS_PLUS = GROUPS.register("catsplus_group", () -> CreativeTabRegistry.create(Text.translatable(Constants.MESSAGE_CATS_GROUP_TITLE), () -> new ItemStack(ModItems.CAT_BAG))); }