Skip to content

Commit

Permalink
Port data stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
HyCraftHD committed Jul 31, 2024
1 parent ec6409d commit bb3d351
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -16,8 +12,8 @@ public UsefulBackpacksLootTableProvider(GenerationData generationData) {
}

@Override
public void register(BiConsumer<ResourceLocation, LootTable> consumer) {
registerBlock(FILTER_CONFIGURATOR, addBasicBlockLootTable(FILTER_CONFIGURATOR.get()), consumer);
public void register(LootTableRegister register) {
registerBlock(FILTER_CONFIGURATOR, addBasicBlockLootTable(FILTER_CONFIGURATOR.get()), register);
}

}

0 comments on commit bb3d351

Please sign in to comment.