From a6567c90da3bf78f468dece496ce9fe16da6b0c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Thu, 21 Jul 2016 10:59:34 +0200
Subject: [PATCH] Tomato soup

---
 TODO.txt                                      |   1 -
 src/java/mmm/food/FMealInBowl.java            |  69 ++++++++++++++++++
 src/java/mmm/food/FMeals.java                 |   4 +
 src/resources/assets/mmm/lang/en_US.lang      |   2 +
 .../models/item/food/meal/tomato_soup.json    |   6 ++
 .../textures/items/food/meal/tomato_soup.png  | Bin 0 -> 149 bytes
 6 files changed, 81 insertions(+), 1 deletion(-)
 create mode 100644 src/java/mmm/food/FMealInBowl.java
 create mode 100644 src/resources/assets/mmm/models/item/food/meal/tomato_soup.json
 create mode 100644 src/resources/assets/mmm/textures/items/food/meal/tomato_soup.png

diff --git a/TODO.txt b/TODO.txt
index 9b9584d..0053573 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -20,7 +20,6 @@ food			???		Milk processing
 food			No		Extra recipes
 							Apple pie
 							Ratatouille
-							Tomato stew
 							Pasta w/tomato
 							Beef stew
 							Pizza
diff --git a/src/java/mmm/food/FMealInBowl.java b/src/java/mmm/food/FMealInBowl.java
new file mode 100644
index 0000000..5d33a4d
--- /dev/null
+++ b/src/java/mmm/food/FMealInBowl.java
@@ -0,0 +1,69 @@
+package mmm.food;
+
+
+import javax.annotation.Nullable;
+
+import mmm.core.CRegistry;
+import mmm.core.api.I_RecipeRegistrar;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemFood;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.registry.GameRegistry;
+
+
+
+public class FMealInBowl
+		extends ItemFood
+		implements I_RecipeRegistrar
+{
+
+	private Object[] recipe;
+
+
+	public FMealInBowl( final String name , final int amount , final float saturation , Object... recipe )
+	{
+		super( amount , saturation , false );
+		this.setMaxStackSize( 1 );
+		CRegistry.setIdentifiers( this , "food" , "meal" , name );
+		CRegistry.addItem( this );
+
+		if ( recipe.length == 0 ) {
+			this.recipe = null;
+		} else if ( recipe[ 0 ] instanceof String ) {
+			this.recipe = new Object[ recipe.length + 2 ];
+			System.arraycopy( recipe , 0 , this.recipe , 0 , recipe.length );
+			this.recipe[ recipe.length ] = 'B';
+			this.recipe[ recipe.length + 1 ] = Items.BOWL;
+		} else {
+			this.recipe = new Object[ recipe.length + 1 ];
+			System.arraycopy( recipe , 0 , this.recipe , 0 , recipe.length );
+			this.recipe[ recipe.length ] = Items.BOWL;
+		}
+	}
+
+
+	@Nullable
+	public ItemStack onItemUseFinish( ItemStack stack , World worldIn , EntityLivingBase entityLiving )
+	{
+		super.onItemUseFinish( stack , worldIn , entityLiving );
+		return new ItemStack( Items.BOWL );
+	}
+
+
+	@Override
+	public void registerRecipes( )
+	{
+		if ( this.recipe == null ) {
+			return;
+		}
+		if ( this.recipe[ 0 ] instanceof String ) {
+			GameRegistry.addShapedRecipe( new ItemStack( this ) , recipe );
+		} else {
+			GameRegistry.addShapelessRecipe( new ItemStack( this ) , recipe );
+		}
+		this.recipe = null;
+	}
+
+}
diff --git a/src/java/mmm/food/FMeals.java b/src/java/mmm/food/FMeals.java
index 6155286..53e8543 100644
--- a/src/java/mmm/food/FMeals.java
+++ b/src/java/mmm/food/FMeals.java
@@ -3,6 +3,7 @@ package mmm.food;
 
 import mmm.MmmFood;
 import mmm.MmmMaterials;
+import mmm.MmmPlants;
 import net.minecraft.init.Items;
 
 
@@ -12,6 +13,7 @@ public class FMeals
 
 	public final FCookableMeal SAUSAGE;
 	public final FCookableMeal PASTA;
+	public final FMealInBowl TOMATO_SOUP;
 
 
 	public FMeals( )
@@ -20,6 +22,8 @@ public class FMeals
 				Items.PORKCHOP , MmmMaterials.ITEM.ROCK_SALT , Items.LEATHER );
 		this.PASTA = new FCookableMeal( "pasta" , 2 , 0.7f , 0.5f , false , 1 , //
 				Items.EGG , MmmFood.INGREDIENT.FLOUR );
+		this.TOMATO_SOUP = new FMealInBowl( "tomato_soup" , 8 , 1.1f , //
+				"TTT" , " B " , 'T' , MmmPlants.TOMATO.FRUIT );
 	}
 
 }
diff --git a/src/resources/assets/mmm/lang/en_US.lang b/src/resources/assets/mmm/lang/en_US.lang
index ee2f2c4..a1b9ec1 100644
--- a/src/resources/assets/mmm/lang/en_US.lang
+++ b/src/resources/assets/mmm/lang/en_US.lang
@@ -152,6 +152,8 @@ item.mmm.food.meal.sausage.cooked.name=Sausage
 item.mmm.food.meal.pasta.raw.name=Pasta Dough
 item.mmm.food.meal.pasta.cooked.name=Pasta
 
+item.mmm.food.meal.tomato_soup.name=Tomato Soup
+
 
 tile.mmm.deco.smoothstone.limestone.name=Polished Limestone
 tile.mmm.deco.smoothstone.basalt.name=Polished Basalt
diff --git a/src/resources/assets/mmm/models/item/food/meal/tomato_soup.json b/src/resources/assets/mmm/models/item/food/meal/tomato_soup.json
new file mode 100644
index 0000000..685c671
--- /dev/null
+++ b/src/resources/assets/mmm/models/item/food/meal/tomato_soup.json
@@ -0,0 +1,6 @@
+{
+    "parent": "minecraft:item/generated",
+    "textures": {
+        "layer0": "mmm:items/food/meal/tomato_soup"
+    }
+}
\ No newline at end of file
diff --git a/src/resources/assets/mmm/textures/items/food/meal/tomato_soup.png b/src/resources/assets/mmm/textures/items/food/meal/tomato_soup.png
new file mode 100644
index 0000000000000000000000000000000000000000..d26dadb0c5af9f5f671341e0c175defb090ff9f6
GIT binary patch
literal 149
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`F`h1tAr_~T6C_x-FowO#`M)u7
zk?FpKv}0W#rBw7!wFE13<R>IGB~OT2!*;-6Q&LH<LC@6&r}{brx3G?$#JB@l47(H+
wWO7b+Hhs);`_8p1ZH}LMioi*!b~y%yOuzhY;cKPwKzkTGUHx3vIVCg!09T|kd;kCd

literal 0
HcmV?d00001