Cleanup and fixed some bugs with foods

This commit is contained in:
Adubbz 2013-07-14 08:47:39 +10:00
parent 9ebdaca648
commit 7a141bd959
9 changed files with 67 additions and 31 deletions

View file

@ -2,6 +2,7 @@ package biomesoplenty.items;
import java.util.List;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@ -22,11 +23,40 @@ public class ItemBOPFood extends ItemFood
public ItemBOPFood(int par1)
{
super(par1, 0, 0.0F, false);
setAlwaysEdible();
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
setHasSubtypes(true);
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
boolean alwaysEdible = ReflectionHelper.getPrivateValue(ItemFood.class, (ItemFood)Item.itemsList[itemstack.itemID], "alwaysEdible");
if (itemstack.getItemDamage() == 0)
{
if (player.canEat(true))
{
player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
}
}
if (itemstack.getItemDamage() == 1)
{
if (player.canEat(true))
{
player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
}
}
else
{
if (player.canEat(alwaysEdible))
{
player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
}
}
return itemstack;
}
@Override
public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer player)
{
@ -93,19 +123,29 @@ public class ItemBOPFood extends ItemFood
player.getFoodStats().setFoodLevel(player.getFoodStats().getFoodLevel() + food);
player.getFoodStats().setFoodSaturationLevel(player.getFoodStats().getSaturationLevel() + saturation);
world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
this.onFoodEaten(itemstack, world, player);
super.onFoodEaten(itemstack, world, player);
if (itemstack.getItemDamage() == 4)
{
return new ItemStack(Item.bowlEmpty);
if (!player.inventory.addItemStackToInventory(new ItemStack(Item.bowlEmpty)))
{
player.dropPlayerItem(new ItemStack(Item.bowlEmpty.itemID, 1, 0));
}
}
if (itemstack.getItemDamage() == 5)
{
return new ItemStack(Item.bowlEmpty);
if (!player.inventory.addItemStackToInventory(new ItemStack(Item.bowlEmpty)))
{
player.dropPlayerItem(new ItemStack(Item.bowlEmpty.itemID, 1, 0));
}
}
if (itemstack.getItemDamage() == 6)
{
return new ItemStack(Item.bowlEmpty);
if (!player.inventory.addItemStackToInventory(new ItemStack(Item.bowlEmpty)))
{
player.dropPlayerItem(new ItemStack(Item.bowlEmpty.itemID, 1, 0));
}
}
return itemstack;
}

View file

@ -2,16 +2,14 @@ package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenFir1 extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 11, var4, var5 + 9) && var4 > 2)

View file

@ -2,15 +2,14 @@ package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenFir2 extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 9, var4, var5 + 8) && var4 > 2)

View file

@ -2,15 +2,14 @@ package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenFir3 extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 4, var4, var5 + 4) && var4 > 2)

View file

@ -9,8 +9,9 @@ import net.minecraft.world.gen.feature.WorldGenerator;
public class WorldGenRealMagic extends WorldGenerator
{
public boolean generate(World world, Random rand, int i, int j, int k) {
@Override
public boolean generate(World world, Random rand, int i, int j, int k)
{
world.setBlock(i + 4, j + 22, k + 47, Block.leaves.blockID, 12, 2);
world.setBlock(i + 5, j + 20, k + 45, Block.leaves.blockID, 12, 2);
world.setBlock(i + 5, j + 21, k + 46, Block.leaves.blockID, 12, 2);

View file

@ -9,6 +9,7 @@ import biomesoplenty.api.Blocks;
public class WorldGenRealPineTree extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 10, var4, var5 + 8) && var4 > 2)

View file

@ -8,6 +8,7 @@ import net.minecraft.world.gen.feature.WorldGenerator;
public class WorldGenRealPineTree2 extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 5, var4, var5 + 9) && var4 > 2)

View file

@ -2,16 +2,14 @@ package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenRealRedwood extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 8, var4, var5 + 7) && var4 > 2)

View file

@ -2,15 +2,14 @@ package biomesoplenty.worldgen;
import java.util.Random;
import biomesoplenty.api.Blocks;
import biomesoplenty.configuration.BOPBlocks;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks;
public class WorldGenRealRedwood2 extends WorldGenerator
{
@Override
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
{
while (var1.isAirBlock(var3 + 5, var4, var5 + 5) && var4 > 2)