Skip to content

Commit

Permalink
Wyrm stews
Browse files Browse the repository at this point in the history
  • Loading branch information
Lykrast committed May 17, 2023
1 parent bb527a9 commit dddc0ad
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/main/java/lykrast/bookwyrms/item/ContainerFoodItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package lykrast.bookwyrms.item;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public class ContainerFoodItem extends Item {
//Modified BowlFoodItem based on Farmer's Delight's ConsumableItem to have proper stacking behavior and stuff
//https://github.com/vectorwing/FarmersDelight/blob/1.19/src/main/java/vectorwing/farmersdelight/common/item/ConsumableItem.java

public ContainerFoodItem(Properties properties) {
super(properties);
}

@Override
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity consumer) {
ItemStack containerStack = stack.getCraftingRemainingItem();

if (stack.isEdible()) super.finishUsingItem(stack, level, consumer);
if (stack.isEmpty()) return containerStack;
else {
if (consumer instanceof Player player && !((Player) consumer).getAbilities().instabuild) {
if (!player.getInventory().add(containerStack)) player.drop(containerStack, false);
}
return stack;
}
}

}
25 changes: 25 additions & 0 deletions src/main/java/lykrast/bookwyrms/registry/BWItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
import lykrast.bookwyrms.BookWyrms;
import lykrast.bookwyrms.entity.BookWyrmEntity;
import lykrast.bookwyrms.item.*;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.RegistryObject;

public class BWItems {
public static RegistryObject<Item> analyzer;
public static RegistryObject<Item> bookWyrmRaw, bookWyrmCooked, chadBolus, chadBolusSus, chadPie;
public static RegistryObject<Item> bookWyrmSliceRaw, bookWyrmSliceCooked;
public static RegistryObject<Item> scaleGrey, scaleRed, scaleOrange, scaleGreen, scaleBlue, scaleTeal, scalePurple;
public static RegistryObject<Item> stewGrey, stewRed, stewOrange, stewGreen, stewBlue, stewTeal, stewPurple;
public static RegistryObject<Item> mutagenBase, mutagenGrey, mutagenRed, mutagenOrange, mutagenGreen, mutagenBlue, mutagenTeal, mutagenPurple;
public static RegistryObject<Item> mutagenLvlUp, mutagenLvlDn, mutagenSpdUp, mutagenDgsUp, mutagenDgsDown, mutagenStasis;
public static RegistryObject<Item> spawnEgg;
public static final DeferredRegister<Item> REG = DeferredRegister.create(ForgeRegistries.ITEMS, BookWyrms.MODID);

private static final String FARMERS_DELIGHT = "farmersdelight";
@ObjectHolder(registryName = "minecraft:mob_effect", value = FARMERS_DELIGHT + ":comfort")
public static MobEffect COMFORT = null;

static {
//Put those at the start of the creative tab since they're the most likely things to be wanted
Expand All @@ -50,6 +56,20 @@ public class BWItems {
scaleBlue = initItem("scale_blue", () -> new Item(defP()));
scaleTeal = initItem("scale_teal", () -> new Item(defP()));
scalePurple = initItem("scale_purple", () -> new Item(defP()));

//Can't feed a null into the effect, so separating it like that
if (ModList.get().isLoaded(FARMERS_DELIGHT)) {
stewGrey = initItem("stew_grey", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(16).saturationMod(0.8f).effect(() -> new MobEffectInstance(COMFORT, 5*60*20), 1).build())));
}
else {
stewGrey = initItem("stew_grey", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(16).saturationMod(0.8f).build())));
}
stewRed = initItem("stew_red", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.DAMAGE_BOOST, 3*60*20), 1).build())));
stewOrange = initItem("stew_orange", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 3*60*20), 1).build())));
stewGreen = initItem("stew_green", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.DIG_SPEED, 3*60*20), 1).build())));
stewBlue = initItem("stew_blue", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 3*60*20), 1).build())));
stewTeal = initItem("stew_teal", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.WATER_BREATHING, 3*60*20), 1).build())));
stewPurple = initItem("stew_purple", () -> new ContainerFoodItem(stew(new FoodProperties.Builder().nutrition(12).saturationMod(0.8f).alwaysEat().effect(() -> new MobEffectInstance(MobEffects.SLOW_FALLING, 3*30*20), 1).build())));

mutagenBase = initItem("wyrmutagen_base", () -> new WyrmutagenBase(defP()));
mutagenGrey = initItem("wyrmutagen_grey", () -> new WyrmutagenColor(BookWyrmEntity.GREY, defP()));
Expand All @@ -71,6 +91,11 @@ public static Item.Properties defP() {
return new Item.Properties().tab(ItemGroupBookWyrms.INSTANCE);
}

public static Item.Properties stew(FoodProperties food) {
//Same as Farmer's Delight stews
return defP().craftRemainder(Items.BOWL).stacksTo(16).food(food);
}

public static <I extends Item> RegistryObject<I> initItem(String name, Supplier<I> item) {
REG.register(name, item);
return RegistryObject.create(BookWyrms.rl(name), ForgeRegistries.ITEMS);
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/assets/bookwyrms/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
"item.bookwyrms.scale_teal": "Teal Book Wyrm Scale",
"item.bookwyrms.scale_purple": "Purple Book Wyrm Scale",

"item.bookwyrms.stew_grey": "Gray Book Wyrm Stew",
"item.bookwyrms.stew_red": "Red Book Wyrm Stew",
"item.bookwyrms.stew_orange": "Orange Book Wyrm Stew",
"item.bookwyrms.stew_green": "Green Book Wyrm Stew",
"item.bookwyrms.stew_blue": "Blue Book Wyrm Stew",
"item.bookwyrms.stew_teal": "Teal Book Wyrm Stew",
"item.bookwyrms.stew_purple": "Purple Book Wyrm Stew",

"item.bookwyrms.analyzer": "Book Wyrm Analyzer",

"item.bookwyrms.wyrmutagen_base": "Wyrmutagen Base",
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/assets/bookwyrms/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
"item.bookwyrms.scale_teal": "Écaille de wyrm scribe turquoise",
"item.bookwyrms.scale_purple": "Écaille de wyrm scribe violet",

"item.bookwyrms.stew_grey": "Ragoût de wyrm scribe gris",
"item.bookwyrms.stew_red": "Ragoût de wyrm scribe rouge",
"item.bookwyrms.stew_orange": "Ragoût de wyrm scribe orange",
"item.bookwyrms.stew_green": "Ragoût de wyrm scribe vert",
"item.bookwyrms.stew_blue": "Ragoût de wyrm scribe bleu",
"item.bookwyrms.stew_teal": "Ragoût de wyrm scribe turquoise",
"item.bookwyrms.stew_purple": "Ragoût de wyrm scribe violet",

"item.bookwyrms.analyzer": "Analyseur de wyrm scribe",

"item.bookwyrms.wyrmutagen_base": "Base de wyrmutagène",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_blue"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_green"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_grey"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_orange"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_purple"
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/bookwyrms/models/item/stew_red.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_red"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "bookwyrms:item/stew_teal"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dddc0ad

Please sign in to comment.