From dddc0adf5e0e018c930a40bba3ce61691ed4e9ae Mon Sep 17 00:00:00 2001 From: Lykrast Date: Wed, 17 May 2023 17:15:57 +0200 Subject: [PATCH] Wyrm stews --- .../bookwyrms/item/ContainerFoodItem.java | 31 ++++++++++++++++++ .../lykrast/bookwyrms/registry/BWItems.java | 25 ++++++++++++++ .../assets/bookwyrms/lang/en_us.json | 8 +++++ .../assets/bookwyrms/lang/fr_fr.json | 8 +++++ .../bookwyrms/models/item/stew_blue.json | 6 ++++ .../bookwyrms/models/item/stew_green.json | 6 ++++ .../bookwyrms/models/item/stew_grey.json | 6 ++++ .../bookwyrms/models/item/stew_orange.json | 6 ++++ .../bookwyrms/models/item/stew_purple.json | 6 ++++ .../bookwyrms/models/item/stew_red.json | 6 ++++ .../bookwyrms/models/item/stew_teal.json | 6 ++++ .../bookwyrms/textures/item/stew_blue.png | Bin 0 -> 321 bytes .../bookwyrms/textures/item/stew_green.png | Bin 0 -> 366 bytes .../bookwyrms/textures/item/stew_grey.png | Bin 0 -> 308 bytes .../bookwyrms/textures/item/stew_orange.png | Bin 0 -> 343 bytes .../bookwyrms/textures/item/stew_purple.png | Bin 0 -> 325 bytes .../bookwyrms/textures/item/stew_red.png | Bin 0 -> 350 bytes .../bookwyrms/textures/item/stew_teal.png | Bin 0 -> 346 bytes 18 files changed, 114 insertions(+) create mode 100644 src/main/java/lykrast/bookwyrms/item/ContainerFoodItem.java create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_blue.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_green.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_grey.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_orange.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_purple.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_red.json create mode 100644 src/main/resources/assets/bookwyrms/models/item/stew_teal.json create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_blue.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_green.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_grey.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_orange.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_purple.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_red.png create mode 100644 src/main/resources/assets/bookwyrms/textures/item/stew_teal.png diff --git a/src/main/java/lykrast/bookwyrms/item/ContainerFoodItem.java b/src/main/java/lykrast/bookwyrms/item/ContainerFoodItem.java new file mode 100644 index 0000000..d2a28ba --- /dev/null +++ b/src/main/java/lykrast/bookwyrms/item/ContainerFoodItem.java @@ -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; + } + } + +} diff --git a/src/main/java/lykrast/bookwyrms/registry/BWItems.java b/src/main/java/lykrast/bookwyrms/registry/BWItems.java index 7ee33d7..b89f5c8 100644 --- a/src/main/java/lykrast/bookwyrms/registry/BWItems.java +++ b/src/main/java/lykrast/bookwyrms/registry/BWItems.java @@ -5,14 +5,17 @@ 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 { @@ -20,12 +23,15 @@ public class BWItems { public static RegistryObject bookWyrmRaw, bookWyrmCooked, chadBolus, chadBolusSus, chadPie; public static RegistryObject bookWyrmSliceRaw, bookWyrmSliceCooked; public static RegistryObject scaleGrey, scaleRed, scaleOrange, scaleGreen, scaleBlue, scaleTeal, scalePurple; + public static RegistryObject stewGrey, stewRed, stewOrange, stewGreen, stewBlue, stewTeal, stewPurple; public static RegistryObject mutagenBase, mutagenGrey, mutagenRed, mutagenOrange, mutagenGreen, mutagenBlue, mutagenTeal, mutagenPurple; public static RegistryObject mutagenLvlUp, mutagenLvlDn, mutagenSpdUp, mutagenDgsUp, mutagenDgsDown, mutagenStasis; public static RegistryObject spawnEgg; public static final DeferredRegister 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 @@ -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())); @@ -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 RegistryObject initItem(String name, Supplier item) { REG.register(name, item); return RegistryObject.create(BookWyrms.rl(name), ForgeRegistries.ITEMS); diff --git a/src/main/resources/assets/bookwyrms/lang/en_us.json b/src/main/resources/assets/bookwyrms/lang/en_us.json index 52d4f46..2650682 100644 --- a/src/main/resources/assets/bookwyrms/lang/en_us.json +++ b/src/main/resources/assets/bookwyrms/lang/en_us.json @@ -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", diff --git a/src/main/resources/assets/bookwyrms/lang/fr_fr.json b/src/main/resources/assets/bookwyrms/lang/fr_fr.json index 4bf99f8..c09c872 100644 --- a/src/main/resources/assets/bookwyrms/lang/fr_fr.json +++ b/src/main/resources/assets/bookwyrms/lang/fr_fr.json @@ -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", diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_blue.json b/src/main/resources/assets/bookwyrms/models/item/stew_blue.json new file mode 100644 index 0000000..4365c6e --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_blue.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_blue" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_green.json b/src/main/resources/assets/bookwyrms/models/item/stew_green.json new file mode 100644 index 0000000..e84b338 --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_green.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_green" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_grey.json b/src/main/resources/assets/bookwyrms/models/item/stew_grey.json new file mode 100644 index 0000000..dba3cf2 --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_grey.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_grey" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_orange.json b/src/main/resources/assets/bookwyrms/models/item/stew_orange.json new file mode 100644 index 0000000..3fae032 --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_orange.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_orange" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_purple.json b/src/main/resources/assets/bookwyrms/models/item/stew_purple.json new file mode 100644 index 0000000..9b0a676 --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_purple.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_purple" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_red.json b/src/main/resources/assets/bookwyrms/models/item/stew_red.json new file mode 100644 index 0000000..023d51a --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_red.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_red" + } +} diff --git a/src/main/resources/assets/bookwyrms/models/item/stew_teal.json b/src/main/resources/assets/bookwyrms/models/item/stew_teal.json new file mode 100644 index 0000000..710f825 --- /dev/null +++ b/src/main/resources/assets/bookwyrms/models/item/stew_teal.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "bookwyrms:item/stew_teal" + } +} diff --git a/src/main/resources/assets/bookwyrms/textures/item/stew_blue.png b/src/main/resources/assets/bookwyrms/textures/item/stew_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..23d31b3f0246615ff980ef20e0d334e4e42f4b7e GIT binary patch literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1IgzyO~RS0F7f z%4DU^W}wJvugx87$yw;nALwdO7H6Sg6JQXW(_+WIB|>0Ut=Gpkmj9P^POr_ji)qp= zUgA@+E@aX^$@Z&a^Zpw&KIdEe-+$ZxN0--}G@HW-G*r4I$S;`TKTdEYv&a;vtlZPZ zF+^hO-1Db}4k_@oCN@2tG$mj~!h!Gg0UM`pJh$W1n}7M6I)nb_@;%%=UG)UJd*D?58qRH|piR^-zzB5eaCX`NCGuv!S^DfEDJ)+fSiVYFj3w~B3{(NN$o6ov`RZFD^&S literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/bookwyrms/textures/item/stew_green.png b/src/main/resources/assets/bookwyrms/textures/item/stew_green.png new file mode 100644 index 0000000000000000000000000000000000000000..2061452e752490207a810eb1bffee946afdb9d71 GIT binary patch literal 366 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1Igv;dzFS0F7f z%4DU^W}wJvugx87$yutw#1O#1oX%|OpsSl>Ug*#75@=l(XW^P^9#Z3+S{b*-lHqa| z@2pxc`B^f?`wU8&WAdlP2d?nQc@qD>kMsX>`#rNG8rJ5XUYq^@VEN?(9gi-r3Ej8x zDbOaRk|4iehW~_s-rvdlfvP(^T^vIsrsnpa6gs3Jz{=RXhFM8Kk?Y|9|DJ&{L1DkH z#eU{%zQAYrhgELpcWM5K?Dg$$n_M$Q>zI%2%-(v)nzii7^Q)%uuT8q9;}aPY9iNb%QjnLIQCwYFSJjgy zH>=ibPpA5x*%7DLX7~4XEm*K%LvC3y&^XDGAirRS|2Tj_u;*Q%q9RWh#}J9BbI%_X zI;_Cq8n`iV#RaJ;GyeRaeyzu>+b6tscXb=@xxd?|117a(GoxeA zLnnYqvQ03E{M>FVdQ I&MBb@04ytuL;wH) literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/bookwyrms/textures/item/stew_purple.png b/src/main/resources/assets/bookwyrms/textures/item/stew_purple.png new file mode 100644 index 0000000000000000000000000000000000000000..535b169dee1d0c4b9943203c65033fd66ba53c40 GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1IgkN}?$S0F7f z%48tLWu?w$pvY;j%^hsX>7y-N=+7VMYEa;!S{7&FC?6eclrufuZC0(}o}8wgZa z?&;zfA~ALDc}KBB3OufXNx2FvTp?W3-qg=uR1wAA_bdJVJfB5Zo=#jgKk4+rwqOsj zg$HUlj%xS_y|t-2H!FXQxF;vul~uWZmcH+}XJnt z8v4k?<40WPoffW_8+rPgqW8>>*u1p%^xEu?mz*vi=(vAw_M^*detdix)g8_av_qjJ z$S;`TKYlQ2*4i?l+6GS-#}J9Bz30!0H7SU=CN6mJN!wAy<5KPa?NhF-37h=wP0eQK z6Y;GI`^#r8J>#`Eah>XYHyah3Rfm3eM9KzSX}PgX_MFufy|tI=BUP7 Rvw&`4@O1TaS?83{1OTr&n>PRe literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/bookwyrms/textures/item/stew_teal.png b/src/main/resources/assets/bookwyrms/textures/item/stew_teal.png new file mode 100644 index 0000000000000000000000000000000000000000..a858ef87190aaef73681632eab1b6793f3100fe5 GIT binary patch literal 346 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1Igr~sc3S0F7f z%4DU^W}wJvugx87$>|s%Sm@6mnl2aUYETwu5m%t9nqM@l)+?sjC~~y{!<_Oxvm;Kg z&9-mr)ZDPmblJ(UefJoipSO7Q$oJ-{;t!WDALw{=c}>Uv&$&Eak7F}1hx`v*>*=V6Z{D3glzX)FhlKsU8b)0ic1PupQ}zMf O!{F)a=d#Wzp$P!G5tfwz literal 0 HcmV?d00001