-
Notifications
You must be signed in to change notification settings - Fork 81
/
ItemNaturaEdibleSoup.java
56 lines (45 loc) · 1.87 KB
/
ItemNaturaEdibleSoup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.progwml6.natura.shared.item.food;
import javax.annotation.Nullable;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemNaturaEdibleSoup extends ItemNaturaEdible
{
protected TIntObjectHashMap<ItemStack> bowlsList;
public ItemNaturaEdibleSoup()
{
super();
this.bowlsList = new TIntObjectHashMap<>();
}
public ItemStack addFood(int meta, int food, float saturation, int duration, String name, ItemStack bowl, PotionEffect... effects)
{
return this.addFood(meta, food, saturation, duration, name, bowl, effects.length > 0, effects);
}
public ItemStack addFood(int meta, int food, float saturation, int duration, String name, ItemStack bowl, boolean alwaysEdible, PotionEffect... effects)
{
this.bowlsList.put(meta, bowl);
return super.addFood(meta, food, saturation, duration, name, alwaysEdible, effects);
}
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
@Override
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
super.onItemUseFinish(stack, worldIn, entityLiving);
ItemStack bowl = this.bowlsList.get(stack.getMetadata()).copy();
if (entityLiving instanceof EntityPlayer)
{
if (!((EntityPlayer) entityLiving).inventory.addItemStackToInventory(bowl))
{
((EntityPlayer) entityLiving).dropItem(bowl, false, false);
}
}
return stack.getCount() <= 0 ? ItemStack.EMPTY : stack;
}
}