Skip to content

Commit

Permalink
Use common food tags (#10355)
Browse files Browse the repository at this point in the history
Add food tags to all food items
Use more specific food tags where applicable (like bread or soup), I added them to my best guess by googling what the foods are
  • Loading branch information
Thodor12 authored Oct 27, 2024
1 parent 33d226b commit 984ad9b
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 51 deletions.
31 changes: 31 additions & 0 deletions src/datagen/generated/minecolonies/data/c/tags/item/foods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"values": [
"minecolonies:milky_bread",
"minecolonies:sugary_bread",
"minecolonies:golden_bread",
"minecolonies:chorus_bread",
"minecolonies:cabochis",
"minecolonies:cheddar_cheese",
"minecolonies:congee",
"minecolonies:cooked_rice",
"minecolonies:eggplant_dolma",
"minecolonies:feta_cheese",
"minecolonies:flatbread",
"minecolonies:hand_pie",
"minecolonies:lamb_stew",
"minecolonies:lembas_scone",
"minecolonies:manchet_bread",
"minecolonies:muffin",
"minecolonies:pasta_plain",
"minecolonies:pasta_tomato",
"minecolonies:pepper_hummus",
"minecolonies:pita_hummus",
"minecolonies:pottage",
"minecolonies:rice_ball",
"minecolonies:stew_trencher",
"minecolonies:stuffed_pepper",
"minecolonies:stuffed_pita",
"minecolonies:sushi_roll",
"minecolonies:tofu"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"values": [
"minecolonies:milky_bread",
"minecolonies:sugary_bread",
"minecolonies:golden_bread",
"minecolonies:chorus_bread",
"minecolonies:flatbread",
"minecolonies:hand_pie",
"minecolonies:lembas_scone",
"minecolonies:manchet_bread",
"minecolonies:muffin",
"minecolonies:stew_trencher",
"minecolonies:stuffed_pita"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecolonies:hand_pie",
"minecolonies:muffin"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecolonies:lamb_stew"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecolonies:golden_bread"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"minecolonies:cabochis",
"minecolonies:lamb_stew",
"minecolonies:pottage"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"values": [
"minecolonies:cabochis",
"minecolonies:eggplant_dolma",
"minecolonies:pottage",
"minecolonies:stuffed_pepper",
"minecolonies:stuffed_pita"
]
}
85 changes: 60 additions & 25 deletions src/main/java/com/minecolonies/api/items/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.minecolonies.api.items;

import com.minecolonies.core.items.ItemFood;
import net.minecraft.world.item.Item;

import java.util.List;

/**
* Class handling the registering of the mod items.
* <p>
Expand Down Expand Up @@ -79,39 +82,71 @@ public final class ModItems
public static Item buildGoggles;
public static Item scanAnalyzer;

public static Item butter;
public static Item cabochis;
public static Item cheddar_cheese;
public static Item congee;
public static Item cooked_rice;
public static Item eggplant_dolma;
public static Item feta_cheese;
public static Item flatbread;
public static Item hand_pie;
public static Item lamb_stew;
public static Item lembas_scone;
public static Item manchet_bread;
public static Item manchet_dough;
public static Item muffin;
public static ItemFood cabochis;
public static ItemFood cheddar_cheese;
public static ItemFood congee;
public static ItemFood cooked_rice;
public static ItemFood eggplant_dolma;
public static ItemFood feta_cheese;
public static ItemFood flatbread;
public static ItemFood hand_pie;
public static ItemFood lamb_stew;
public static ItemFood lembas_scone;
public static ItemFood manchet_bread;
public static ItemFood muffin;
public static ItemFood pasta_plain;
public static ItemFood pasta_tomato;
public static ItemFood pepper_hummus;
public static ItemFood pita_hummus;
public static ItemFood pottage;
public static ItemFood rice_ball;
public static ItemFood stew_trencher;
public static ItemFood stuffed_pepper;
public static ItemFood stuffed_pita;
public static ItemFood sushi_roll;
public static ItemFood tofu;

public static Item muffin_dough;
public static Item pasta_plain;
public static Item pasta_tomato;
public static Item pepper_hummus;
public static Item pita_hummus;
public static Item pottage;
public static Item manchet_dough;
public static Item raw_noodle;
public static Item rice_ball;
public static Item stew_trencher;
public static Item stuffed_pepper;
public static Item stuffed_pita;
public static Item sushi_roll;
public static Item tofu;
public static Item butter;

public static Item large_water_bottle;
public static Item large_milk_bottle;
public static Item large_soy_milk_bottle;
public static Item large_empty_bottle;

/**
* Get a list of all possible food items.
*
* @return a list of food items.
*/
public static List<ItemFood> getFoodItems()
{
return List.of(cabochis,
cheddar_cheese,
congee,
cooked_rice,
eggplant_dolma,
feta_cheese,
flatbread,
hand_pie,
lamb_stew,
lembas_scone,
manchet_bread,
muffin,
pasta_plain,
pasta_tomato,
pepper_hummus,
pita_hummus,
pottage,
rice_ball,
stew_trencher,
stuffed_pepper,
stuffed_pita,
sushi_roll,
tofu);
}

/**
* Private constructor to hide the implicit public one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,26 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.TagKey;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.common.DeferredSpawnEggItem;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.RegisterEvent;

import java.util.EnumMap;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Stream;

import static com.minecolonies.api.blocks.decorative.AbstractBlockGate.IRON_GATE;
import static com.minecolonies.api.blocks.decorative.AbstractBlockGate.WOODEN_GATE;
Expand Down Expand Up @@ -147,53 +153,53 @@ public static void init(final Registry<Item> registry)
ModItems.scanAnalyzer = new ItemScanAnalyzer("scan_analyzer", new Item.Properties());

// Tier 1 Food Items
ModItems.cheddar_cheese = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(4).saturationModifier(0.6F).build()), ModJobs.CHEF_ID.getPath(), 1);
ModItems.feta_cheese = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(4).saturationModifier(0.6F).build()), ModJobs.CHEF_ID.getPath(), 1);
ModItems.cooked_rice = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(4).saturationModifier(0.6F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 1);
ModItems.tofu = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(4).saturationModifier(0.6F).build()), ModJobs.CHEF_ID.getPath(), 1);
ModItems.flatbread = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(4).saturationModifier(0.6F).build()), ModJobs.BAKER_ID.getPath(), 1);
ModItems.cheddar_cheese = registerFoodItem(1, ModJobs.CHEF_ID, (builder) -> builder.nutrition(4).saturationModifier(0.6F).build());
ModItems.feta_cheese = registerFoodItem(1, ModJobs.CHEF_ID, (builder) -> builder.nutrition(4).saturationModifier(0.6F).build());
ModItems.cooked_rice = registerFoodItem(1, ModJobs.CHEF_ID, builder -> builder.nutrition(4).saturationModifier(0.6F).usingConvertsTo(Items.BOWL).build());
ModItems.tofu = registerFoodItem(1, ModJobs.CHEF_ID, builder -> builder.nutrition(4).saturationModifier(0.6F).build());
ModItems.flatbread = registerFoodItem(1, ModJobs.BAKER_ID, Set.of(Tags.Items.FOODS_BREAD), builder -> builder.nutrition(4).saturationModifier(0.6F).build());

// Tier 2 Food Items
ModItems.manchet_bread = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).build()), ModJobs.BAKER_ID.getPath(), 2);
ModItems.lembas_scone = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).build()), ModJobs.BAKER_ID.getPath(), 2);
ModItems.muffin = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).build()), ModJobs.BAKER_ID.getPath(), 2);
ModItems.pottage = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.pasta_plain = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.manchet_bread = registerFoodItem(2, ModJobs.BAKER_ID, Set.of(Tags.Items.FOODS_BREAD), builder -> builder.nutrition(6).saturationModifier(1.0F).build());
ModItems.lembas_scone = registerFoodItem(2, ModJobs.BAKER_ID, Set.of(Tags.Items.FOODS_BREAD), builder -> builder.nutrition(6).saturationModifier(1.0F).build());
ModItems.muffin = registerFoodItem(2, ModJobs.BAKER_ID, Set.of(Tags.Items.FOODS_BREAD, Tags.Items.FOODS_CANDY), builder -> builder.nutrition(6).saturationModifier(1.0F).build());
ModItems.pottage = registerFoodItem(2, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_SOUP, Tags.Items.FOODS_VEGETABLE), builder -> builder.nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build());
ModItems.pasta_plain = registerFoodItem(2, ModJobs.CHEF_ID, builder -> builder.nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build());

// Tier 3 Food items
ModItems.hand_pie = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.hand_pie = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_BREAD, Tags.Items.FOODS_CANDY), builder -> builder.nutrition(8).saturationModifier(1.2F).build());

// Cold Biomes
// Tier 2
ModItems.cabochis = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.cabochis = registerFoodItem(2, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_SOUP, Tags.Items.FOODS_VEGETABLE), builder -> builder.nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build());
// Tier 3
ModItems.lamb_stew = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.lamb_stew = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_SOUP, Tags.Items.FOODS_COOKED_MEAT), builder -> builder.nutrition(8).saturationModifier(1.2F).usingConvertsTo(Items.BOWL).build());

// Hot Humid Biomes
// Tier 2
ModItems.rice_ball = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.rice_ball = registerFoodItem(2, ModJobs.CHEF_ID, builder -> builder.nutrition(6).saturationModifier(1.0F).build());
// Tier 3
ModItems.sushi_roll = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.sushi_roll = registerFoodItem(3, ModJobs.CHEF_ID, builder -> builder.nutrition(8).saturationModifier(1.2F).build());

// Temperate Biomes
// Tier 2
ModItems.pasta_tomato = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.pasta_tomato = registerFoodItem(2, ModJobs.CHEF_ID, builder -> builder.nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build());
// Tier 3
ModItems.eggplant_dolma = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.stuffed_pita = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.eggplant_dolma = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_VEGETABLE), builder -> builder.nutrition(8).saturationModifier(1.2F).build());
ModItems.stuffed_pita = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_BREAD, Tags.Items.FOODS_VEGETABLE), builder -> builder.nutrition(8).saturationModifier(1.2F).build());

// Hot Dry Biomes
// Tier 2
ModItems.pepper_hummus = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.pepper_hummus = registerFoodItem(2, ModJobs.CHEF_ID, builder -> builder.nutrition(6).saturationModifier(1.0F).build());
// Tier 3
ModItems.pita_hummus = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.pita_hummus = registerFoodItem(3, ModJobs.CHEF_ID, builder -> builder.nutrition(8).saturationModifier(1.2F).build());

// Require trading
// Tier 2
ModItems.congee = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build()), ModJobs.CHEF_ID.getPath(), 2);
ModItems.congee = registerFoodItem(2, ModJobs.CHEF_ID, builder -> builder.nutrition(6).saturationModifier(1.0F).usingConvertsTo(Items.BOWL).build());
// Tier 3
ModItems.stew_trencher = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.stuffed_pepper = new ItemFood((new Item.Properties()).food(new FoodProperties.Builder().nutrition(8).saturationModifier(1.2F).build()), ModJobs.CHEF_ID.getPath(), 3);
ModItems.stew_trencher = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_BREAD), builder -> builder.nutrition(8).saturationModifier(1.2F).build());
ModItems.stuffed_pepper = registerFoodItem(3, ModJobs.CHEF_ID, Set.of(Tags.Items.FOODS_VEGETABLE), builder -> builder.nutrition(8).saturationModifier(1.2F).build());

// Just dough
ModItems.muffin_dough = new Item((new Item.Properties()));
Expand Down Expand Up @@ -443,4 +449,22 @@ public static void init(final Registry<Item> registry)
0
));

public static ItemFood registerFoodItem(final int tier, final ResourceLocation worker, final Consumer<FoodProperties.Builder> foodPropertiesGenerator)
{
return registerFoodItem(tier, worker, Set.of(), foodPropertiesGenerator);
}

public static ItemFood registerFoodItem(
final int tier,
final ResourceLocation worker,
final Set<TagKey<Item>> foodTags,
final Consumer<FoodProperties.Builder> foodPropertiesGenerator)
{
final FoodProperties.Builder foodPropertiesBuilder = new FoodProperties.Builder();
foodPropertiesGenerator.accept(foodPropertiesBuilder);
final Properties itemProperties = new Properties().food(foodPropertiesBuilder.build());

final List<TagKey<Item>> tags = Stream.concat(Stream.of(Tags.Items.FOODS), foodTags.stream()).toList();
return new ItemFood(itemProperties, worker.getPath(), tier, tags);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.minecolonies.api.items.ModItems;
import com.minecolonies.api.items.ModTags;
import com.minecolonies.api.util.constant.TagConstants;
import com.minecolonies.core.items.ItemFood;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.ItemTagsProvider;
Expand Down Expand Up @@ -40,7 +41,7 @@ public DefaultItemTagsProvider(
}

@Override
protected void addTags(final HolderLookup.Provider p_256380_)
protected void addTags(final @NotNull HolderLookup.Provider provider)
{
ModTags.init(); // apparently runData doesn't run work queued in common setup

Expand Down Expand Up @@ -498,6 +499,23 @@ protected void addTags(final HolderLookup.Provider p_256380_)

tag(ModTags.ignoreNBT)
.addTag(ItemTags.BANNERS);

tag(Tags.Items.FOODS)
.add(ModItems.milkyBread, ModItems.sugaryBread, ModItems.goldenBread, ModItems.chorusBread);

tag(Tags.Items.FOODS_BREAD)
.add(ModItems.milkyBread, ModItems.sugaryBread, ModItems.goldenBread, ModItems.chorusBread);

tag(Tags.Items.FOODS_GOLDEN)
.add(ModItems.goldenBread);

for (final ItemFood foodItem : ModItems.getFoodItems())
{
for (final TagKey<Item> tagKey : foodItem.getTags())
{
tag(tagKey).add(foodItem);
}
}
}

@NotNull
Expand Down
Loading

0 comments on commit 984ad9b

Please sign in to comment.