More work on foods
This commit is contained in:
parent
3d97fa49ba
commit
ab36d51c2c
5 changed files with 339 additions and 198 deletions
|
@ -1,11 +1,20 @@
|
|||
package dark.farmtech;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import dark.core.common.RecipeLoader;
|
||||
import dark.farmtech.item.ItemFarmFood;
|
||||
import dark.farmtech.item.ItemFarmFood.FarmFood;
|
||||
|
||||
public class FTRecipeLoader extends RecipeLoader
|
||||
{
|
||||
private static FTRecipeLoader instance;
|
||||
|
||||
public static Item itemFood;
|
||||
|
||||
public static FTRecipeLoader instance()
|
||||
{
|
||||
if (instance == null)
|
||||
|
@ -19,5 +28,26 @@ public class FTRecipeLoader extends RecipeLoader
|
|||
public void loadRecipes()
|
||||
{
|
||||
super.loadRecipes();
|
||||
this.loadFood();
|
||||
}
|
||||
|
||||
public void loadFood()
|
||||
{
|
||||
if (itemFood instanceof ItemFarmFood)
|
||||
{
|
||||
FurnaceRecipes.smelting().addSmelting(itemFood.itemID, FarmFood.TurkeyRaw.ordinal(), new ItemStack(itemFood.itemID, 1, FarmFood.TurkeyCooked.ordinal()), 0.3f);
|
||||
if (FarmTech.getDate().getA() == Calendar.OCTOBER)
|
||||
{
|
||||
//TODO load up hollow eve foods
|
||||
}
|
||||
else if (FarmTech.getDate().getA() == Calendar.NOVEMBER)
|
||||
{
|
||||
//TODO load up thanks giving foods
|
||||
}
|
||||
else if (FarmTech.getDate().getA() == Calendar.DECEMBER)
|
||||
{
|
||||
//TODO load up xmas and other holiday foods
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
src/dark/farmtech/blocks/BlockCookingPot.java
Normal file
6
src/dark/farmtech/blocks/BlockCookingPot.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package dark.farmtech.blocks;
|
||||
|
||||
public class BlockCookingPot
|
||||
{
|
||||
|
||||
}
|
|
@ -14,15 +14,15 @@ import dark.core.prefab.ModPrefab;
|
|||
import dark.farmtech.FarmTech;
|
||||
|
||||
/** Generic block set containing farm blocks: mulch, fertilizer, fertile dirt, mud
|
||||
*
|
||||
*
|
||||
* mulch/fertilizer -> fertileDirt -> mud -> dirt
|
||||
*
|
||||
*
|
||||
* @mulch is a decor version of fertilizer made from wood. decays very slowly when actually used for
|
||||
* crops. Design is to be used with small plant for decor
|
||||
*
|
||||
*
|
||||
* @fertilizer enriches the soil and is used to grow crops faster fertilizer can be created from
|
||||
* anything using several means
|
||||
*
|
||||
*
|
||||
* @author darkguardsman */
|
||||
public class BlockFarmSoil extends Block
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public class BlockFarmSoil extends Block
|
|||
{
|
||||
super(FarmTech.CONFIGURATION.getBlock("FarmSoil", ModPrefab.getNextID()).getInt(), Material.clay);
|
||||
this.setUnlocalizedName("FarmBlock");
|
||||
this.setCreativeTab(FarmTech.TabFarmTech);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
298
src/dark/farmtech/item/ItemFarmFood.java
Normal file
298
src/dark/farmtech/item/ItemFarmFood.java
Normal file
|
@ -0,0 +1,298 @@
|
|||
package dark.farmtech.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
|
||||
import dark.core.prefab.helpers.ItemWorldHelper;
|
||||
import dark.farmtech.FarmTech;
|
||||
|
||||
/** Item for storing all kinds of food based items including meats, fruits, pies, cakes, breads, etc
|
||||
* we have 1000s of meta to work with :)
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ItemFarmFood extends Item implements IExtraItemInfo
|
||||
{
|
||||
|
||||
public static boolean loadIllegalDrugs = true;
|
||||
|
||||
public ItemFarmFood(int par1)
|
||||
{
|
||||
super(FarmTech.CONFIGURATION.getItem("Food", FarmTech.getNextID()).getInt());
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabs.tabFood);
|
||||
this.setUnlocalizedName("FarmFood");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
FarmFood food = FarmFood.get(itemStack);
|
||||
if (player != null && food != null)
|
||||
{
|
||||
--itemStack.stackSize;
|
||||
//TODO add stats and achievements for some of the foods
|
||||
world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
if (!world.isRemote && food.type == FoodType.MEAT && world.rand.nextFloat() < 0.3f)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.hunger.id, 300, 0));
|
||||
}
|
||||
ItemStack re = null;
|
||||
if (food.type == FoodType.CUP)
|
||||
{
|
||||
re = new ItemStack(this, 1, FarmFood.Cup.ordinal());
|
||||
}
|
||||
else if (food.type == FoodType.JAR)
|
||||
{
|
||||
re = new ItemStack(this, 1, FarmFood.JAR.ordinal());
|
||||
}
|
||||
else if (food.type == FoodType.BOTTLE)
|
||||
{
|
||||
re = new ItemStack(this, 1, FarmFood.BOTTLE.ordinal());
|
||||
}
|
||||
else if (food.type == FoodType.PROCESSED)
|
||||
{
|
||||
re = new ItemStack(this, 1, FarmFood.TRASH.ordinal());
|
||||
}
|
||||
if (re != null)
|
||||
{
|
||||
if (!player.inventory.addItemStackToInventory(re))
|
||||
{
|
||||
ItemWorldHelper.dropItemStack(player.worldObj, new Vector3(player), re, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.eat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
FarmFood food = FarmFood.get(itemStack);
|
||||
if (food != null && food.type.canEat && player.canEat(food.type.canEat))
|
||||
{
|
||||
player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
food.icon = par1IconRegister.registerIcon(FarmTech.instance.PREFIX + "food_" + food.name);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getIconFromDamage(int par1)
|
||||
{
|
||||
FarmFood food = FarmFood.get(par1);
|
||||
if (food != null)
|
||||
{
|
||||
return food.icon;
|
||||
}
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int itemID, CreativeTabs tab, List list)
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
if (food.type != FoodType.ILLEGAL_DRUGS || this.loadIllegalDrugs)
|
||||
{
|
||||
list.add(new ItemStack(this.itemID, 1, food.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasExtraConfigs()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
if (food.foodValue != 0 && food.saturation != 0)
|
||||
{
|
||||
food.foodValue = (float) config.get("FoodValue", food.name, food.foodValue).getDouble(food.foodValue);
|
||||
food.saturation = (float) config.get("FoodSaturation", food.name, food.saturation).getDouble(food.saturation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadOreNames()
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
OreDictionary.registerOre(food.name, new ItemStack(this, 1, food.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
/** enum that stores data for each meta value that represents a food object for the item
|
||||
*
|
||||
* @Source http://urbanext.illinois.edu/herbs/list.cfm
|
||||
* @author DarkGuardsman */
|
||||
public static enum FarmFood
|
||||
{
|
||||
Cup("Cup", FoodType.ITEM),
|
||||
JAR("Jar", FoodType.ITEM),
|
||||
TRASH("Trash", FoodType.ITEM),
|
||||
BOTTLE("Cup", FoodType.ITEM),
|
||||
//Turkey
|
||||
TurkeyRaw("TurkeyRaw", FoodType.MEAT, 2, 0.3F),
|
||||
TurkeyCooked("TurkeyCooked", FoodType.COOKED_MEAT, 6, 0.6F),
|
||||
TGTurkeyCooked("TGTurkeyCooked", FoodType.COOKED_MEAT, 9, 0.8F),
|
||||
//cabage
|
||||
HeadOFCabage("RawCabage", FoodType.VEG, 2, 0.2F),
|
||||
CabageSeeds("CabageSeeds", FoodType.SEEDS),
|
||||
HeadOfCookedCabage("CabageCooked", FoodType.VEG, 4, 0.2F),
|
||||
|
||||
//Corn
|
||||
CornCob("RawCornCob", FoodType.VEG, 2, 0.2F),
|
||||
CookedCornCob("CornCob", FoodType.VEG, 4, 0.2F),
|
||||
Corn("Corn", FoodType.VEG, 4, 0.3f),
|
||||
CornSeeds("Corn", FoodType.SEEDS),
|
||||
CookedCorn("CookedCorn", FoodType.VEG, 4, 0.3f),
|
||||
//drinks
|
||||
Coffee("Coffee", FoodType.ITEM),
|
||||
TeaLeaves("TeaLeaves", FoodType.ITEM),
|
||||
CupCoffee("CoffeeCup", FoodType.CUP),
|
||||
CupTea("TeaCup", FoodType.CUP),
|
||||
//Soups
|
||||
VegSoup("VegSoup", FoodType.SOUP),
|
||||
MeatSoup("MeatSoup", FoodType.SOUP),
|
||||
HamCabageSoup("HawCabageSoup", FoodType.SOUP, 2, 0.2F),
|
||||
BeafCabageSoup("BeafCabageSoup", FoodType.SOUP, 2, 0.2F);
|
||||
|
||||
/** Metadata id that this item converts to for each recipe creation */
|
||||
public int returnID = -1;
|
||||
public final FoodType type;
|
||||
/** Name used for translation and icons */
|
||||
final String name;
|
||||
|
||||
float foodValue;
|
||||
float saturation;
|
||||
|
||||
Icon icon;
|
||||
|
||||
private FarmFood(String name, FoodType type)
|
||||
{
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private FarmFood(String name, FoodType type, float foodValue, float saturation)
|
||||
{
|
||||
this(name, type, foodValue, saturation, -1);
|
||||
}
|
||||
|
||||
private FarmFood(String name, FoodType type, float foodValue, float saturation, int returnID)
|
||||
{
|
||||
this(name, type);
|
||||
this.foodValue = foodValue;
|
||||
this.saturation = saturation;
|
||||
this.returnID = returnID;
|
||||
}
|
||||
|
||||
public static FarmFood get(ItemStack stack)
|
||||
{
|
||||
return get(stack != null ? stack.getItemDamage() : -1);
|
||||
}
|
||||
|
||||
public static FarmFood get(int meta)
|
||||
{
|
||||
if (meta >= 0 && meta < FarmFood.values().length)
|
||||
{
|
||||
return FarmFood.values()[meta];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** IDs what the item is and determines how its used
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public static enum FoodType
|
||||
{
|
||||
MEAT(true),
|
||||
COOKED_MEAT(true),
|
||||
VEG(true),
|
||||
SEEDS(false),
|
||||
FRUIT(true),
|
||||
CUP(true),
|
||||
SOUP(true),
|
||||
/** food containers */
|
||||
ITEM(false),
|
||||
/** Herbs used to add to foods */
|
||||
HERB(false),
|
||||
/** Medical Drugs, mainly ones to heal animals */
|
||||
MEDICAL_DRUGS(false),
|
||||
/** Drugs that are considered illegal but are still valid drug items */
|
||||
ILLEGAL_DRUGS(false),
|
||||
/** Food that has been canned */
|
||||
CAN(true),
|
||||
/** Foods that have been sealed in a glass jar. Same as a can */
|
||||
JAR(true),
|
||||
/** Liquids like milk that were bottled */
|
||||
BOTTLE(true),
|
||||
/** Food that comes in a plastic wrapper */
|
||||
PROCESSED(true);
|
||||
|
||||
boolean canEat = true;
|
||||
|
||||
private FoodType(boolean canEat)
|
||||
{
|
||||
this.canEat = canEat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getItemStackLimit(ItemStack stack)
|
||||
{
|
||||
FarmFood food = FarmFood.get(stack);
|
||||
if (food != null)
|
||||
{
|
||||
|
||||
}
|
||||
return 64;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
package dark.farmtech.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.prefab.IExtraInfo.IExtraItemInfo;
|
||||
import dark.farmtech.FarmTech;
|
||||
|
||||
/** Item for storing all kinds of food based items including meats, fruits, pies, cakes, breads, etc
|
||||
* we have 1000s of meta to work with :)
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ItemFood extends Item implements IExtraItemInfo
|
||||
{
|
||||
public ItemFood(int par1)
|
||||
{
|
||||
super(FarmTech.CONFIGURATION.getItem("Food", FarmTech.getNextID()).getInt());
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabs.tabFood);
|
||||
this.setUnlocalizedName("FarmFood");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
FarmFood food = FarmFood.get(itemStack);
|
||||
if (player != null && food != null)
|
||||
{
|
||||
--itemStack.stackSize;
|
||||
//TODO add stats and achievements for some of the foods
|
||||
world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
if (!world.isRemote && food.hasPotion && food.potionID > 0 && world.rand.nextFloat() < food.potionChance)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(food.potionID, food.potionDuration * 20, food.potionAmp));
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.eat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.canEat(true))
|
||||
{
|
||||
player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
food.icon = par1IconRegister.registerIcon(FarmTech.instance.PREFIX + "food_" + food.name);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getIconFromDamage(int par1)
|
||||
{
|
||||
FarmFood food = FarmFood.get(par1);
|
||||
if (food != null)
|
||||
{
|
||||
return food.icon;
|
||||
}
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(this.itemID, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasExtraConfigs()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
food.foodValue = (float) config.get("FoodValue", food.name, food.foodValue).getDouble(food.foodValue);
|
||||
food.saturation = (float) config.get("FoodSaturation", food.name, food.saturation).getDouble(food.saturation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadOreNames()
|
||||
{
|
||||
for (FarmFood food : FarmFood.values())
|
||||
{
|
||||
OreDictionary.registerOre(food.name, new ItemStack(this, 1, food.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
/** enum that stores data for each meta value that represents a food object for the item
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public static enum FarmFood
|
||||
{
|
||||
TurkeyRaw("TurkeyRaw", 1, 2, 0.3F),
|
||||
TurkeyCooked("TurkeyCooked", 6, 0.6F);
|
||||
/** Metadata id that this item converts to for each recipe creation */
|
||||
final int cookedID;
|
||||
/** Name used for translation and icons */
|
||||
final String name;
|
||||
float foodValue;
|
||||
float saturation;
|
||||
boolean hasPotion = false;
|
||||
int potionID, potionDuration, potionAmp;
|
||||
float potionChance;
|
||||
Icon icon;
|
||||
|
||||
private FarmFood(String name, float foodValue, float saturation)
|
||||
{
|
||||
this(name, -1, foodValue, saturation);
|
||||
}
|
||||
|
||||
private FarmFood(String name, int cookedID, float foodValue, float saturation)
|
||||
{
|
||||
this.name = name;
|
||||
this.cookedID = cookedID;
|
||||
//Means the food is raw and can harm the player if not cooked
|
||||
if (cookedID != -1)
|
||||
{
|
||||
this.hasPotion = true;
|
||||
this.potionID = Potion.hunger.id;
|
||||
this.potionDuration = 30;
|
||||
this.potionAmp = 0;
|
||||
this.potionChance = 0.3F;
|
||||
}
|
||||
}
|
||||
|
||||
private FarmFood(String name, int cookedID, float foodValue, float saturation, int pID, int pD, int pA, float pC)
|
||||
{
|
||||
this.name = name;
|
||||
this.cookedID = cookedID;
|
||||
this.hasPotion = true;
|
||||
this.potionID = pID;
|
||||
this.potionDuration = pD;
|
||||
this.potionAmp = pA;
|
||||
this.potionChance = pC;
|
||||
}
|
||||
|
||||
public static FarmFood get(ItemStack stack)
|
||||
{
|
||||
return get(stack != null ? stack.getItemDamage() : -1);
|
||||
}
|
||||
|
||||
public static FarmFood get(int meta)
|
||||
{
|
||||
if (meta >= 0 && meta < FarmFood.values().length)
|
||||
{
|
||||
return FarmFood.values()[meta];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue