From bb3d351cc488631dce5154c2f4842a651e1d213b Mon Sep 17 00:00:00 2001 From: HyCraftHD Date: Wed, 31 Jul 2024 16:10:43 +0200 Subject: [PATCH] Port data stuff --- .../data/UsefulBackpacksDataGenerator.java | 8 +-- .../BackpackCraftingRecipeBuilder.java | 53 ++++++++++++++++--- .../UsefulBackpacksBlockStateProvider.java | 4 +- .../UsefulBackpacksItemModelProvider.java | 2 +- .../UsefulBackpacksItemTagsProvider.java | 4 +- .../UsefulBackpacksLootTableProvider.java | 8 +-- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/UsefulBackpacksDataGenerator.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/UsefulBackpacksDataGenerator.java index 74996c4a..03bed83e 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/UsefulBackpacksDataGenerator.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/UsefulBackpacksDataGenerator.java @@ -9,10 +9,10 @@ import info.u_team.useful_backpacks.data.provider.UsefulBackpacksLanguagesProvider; import info.u_team.useful_backpacks.data.provider.UsefulBackpacksLootTableProvider; import info.u_team.useful_backpacks.data.provider.UsefulBackpacksRecipeProvider; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.fml.common.EventBusSubscriber.Bus; +import net.neoforged.neoforge.data.event.GatherDataEvent; @EventBusSubscriber(modid = UsefulBackpacksMod.MODID, bus = Bus.MOD) public class UsefulBackpacksDataGenerator { diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/builder/BackpackCraftingRecipeBuilder.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/builder/BackpackCraftingRecipeBuilder.java index ca0fa3e6..9a8e96ad 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/builder/BackpackCraftingRecipeBuilder.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/builder/BackpackCraftingRecipeBuilder.java @@ -1,14 +1,22 @@ package info.u_team.useful_backpacks.data.builder; -import info.u_team.u_team_core.util.RecipeBuilderUtil; import info.u_team.useful_backpacks.init.UsefulBackpacksRecipeSerializers; -import net.minecraft.advancements.Advancement; -import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.advancements.Advancement.Builder; +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup.Provider; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.ShapedRecipeBuilder; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeInput; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.Level; +import net.neoforged.neoforge.common.conditions.ICondition; public class BackpackCraftingRecipeBuilder extends ShapedRecipeBuilder { @@ -29,13 +37,46 @@ public void save(RecipeOutput output, ResourceLocation location) { super.save(new RecipeOutput() { @Override - public Advancement.Builder advancement() { + public Builder advancement() { return output.advancement(); } @Override - public void accept(FinishedRecipe recipe) { - output.accept(RecipeBuilderUtil.getRecipeWithSerializer(recipe, UsefulBackpacksRecipeSerializers.BACKPACK)); + public void accept(ResourceLocation id, Recipe recipe, AdvancementHolder advancement, ICondition... conditions) { + // TODO maybe rework + output.accept(id, new Recipe<>() { + + @Override + public boolean matches(RecipeInput input, Level level) { + return false; + } + + @Override + public ItemStack assemble(RecipeInput input, Provider registries) { + return null; + } + + @Override + public boolean canCraftInDimensions(int width, int height) { + return false; + } + + @Override + public ItemStack getResultItem(HolderLookup.Provider registries) { + return null; + } + + @Override + public RecipeSerializer getSerializer() { + return UsefulBackpacksRecipeSerializers.BACKPACK.get(); + } + + @Override + public RecipeType getType() { + return null; + } + + }, advancement, conditions); } }, location); } diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksBlockStateProvider.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksBlockStateProvider.java index 9b4e79a1..a527d919 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksBlockStateProvider.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksBlockStateProvider.java @@ -6,7 +6,7 @@ import info.u_team.u_team_core.data.GenerationData; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; -import net.minecraftforge.client.model.generators.ModelFile; +import net.neoforged.neoforge.client.model.generators.ModelFile; public class UsefulBackpacksBlockStateProvider extends CommonBlockStateProvider { @@ -25,7 +25,7 @@ private ModelFile cubeBottomTop(Block block) { } private ResourceLocation extend(ResourceLocation location, String suffix) { - return new ResourceLocation(location.getNamespace(), location.getPath() + suffix); + return ResourceLocation.fromNamespaceAndPath(location.getNamespace(), location.getPath() + suffix); } } diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemModelProvider.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemModelProvider.java index 5ab9bcca..8cb8f4eb 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemModelProvider.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemModelProvider.java @@ -11,7 +11,7 @@ import info.u_team.u_team_core.data.CommonItemModelProvider; import info.u_team.u_team_core.data.GenerationData; import info.u_team.useful_backpacks.item.BackpackItem; -import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile; +import net.neoforged.neoforge.client.model.generators.ModelFile.UncheckedModelFile; public class UsefulBackpacksItemModelProvider extends CommonItemModelProvider { diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemTagsProvider.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemTagsProvider.java index 4f3d533d..0316c062 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemTagsProvider.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksItemTagsProvider.java @@ -16,7 +16,7 @@ import info.u_team.useful_backpacks.init.UsefulBackpacksCommonTags; import net.minecraft.core.HolderLookup; import net.minecraft.world.item.Items; -import net.minecraftforge.common.Tags; +import net.neoforged.neoforge.common.Tags; public class UsefulBackpacksItemTagsProvider extends CommonItemTagsProvider { @@ -36,7 +36,7 @@ public void register(HolderLookup.Provider provider) { tag(UsefulBackpacksCommonTags.DIAMOND_GEM).add(Items.DIAMOND).addOptionalTag(Tags.Items.GEMS_DIAMOND.location()); tag(UsefulBackpacksCommonTags.IRON_INGOT).add(Items.IRON_INGOT).addOptionalTag(Tags.Items.INGOTS_IRON.location()); tag(UsefulBackpacksCommonTags.END_STONE).add(Items.END_STONE).addOptionalTag(Tags.Items.END_STONES.location()); - tag(UsefulBackpacksCommonTags.NETHER_BRICK_INGOT).add(Items.NETHER_BRICK).addOptionalTag(Tags.Items.INGOTS_NETHER_BRICK.location()); + tag(UsefulBackpacksCommonTags.NETHER_BRICK_INGOT).add(Items.NETHER_BRICK).addOptionalTag(Tags.Items.BRICKS_NETHER.location()); } } \ No newline at end of file diff --git a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksLootTableProvider.java b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksLootTableProvider.java index 135f4bff..650377a7 100644 --- a/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksLootTableProvider.java +++ b/neoforge/src/data/java/info/u_team/useful_backpacks/data/provider/UsefulBackpacksLootTableProvider.java @@ -2,12 +2,8 @@ import static info.u_team.useful_backpacks.init.UsefulBackpacksBlocks.FILTER_CONFIGURATOR; -import java.util.function.BiConsumer; - import info.u_team.u_team_core.data.CommonLootTableProvider; import info.u_team.u_team_core.data.GenerationData; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.storage.loot.LootTable; public class UsefulBackpacksLootTableProvider extends CommonLootTableProvider { @@ -16,8 +12,8 @@ public UsefulBackpacksLootTableProvider(GenerationData generationData) { } @Override - public void register(BiConsumer consumer) { - registerBlock(FILTER_CONFIGURATOR, addBasicBlockLootTable(FILTER_CONFIGURATOR.get()), consumer); + public void register(LootTableRegister register) { + registerBlock(FILTER_CONFIGURATOR, addBasicBlockLootTable(FILTER_CONFIGURATOR.get()), register); } }