-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathFoodEvent.java
128 lines (118 loc) · 4.23 KB
/
FoodEvent.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package squeek.applecore.api.food;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.FoodStats;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import squeek.applecore.api.AppleCoreAPI;
import javax.annotation.Nonnull;
/**
* Base class for all FoodEvent events.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public abstract class FoodEvent extends Event
{
/**
* Fired every time food values are retrieved to allow player-independent control over their values.
*
* This event is fired in {@link FoodStats#addStats(ItemFood, ItemStack)} and in {@link AppleCoreAPI}.<br>
* <br>
* {@link #foodValues} contains the values of the {@link #food}.<br>
* {@link #unmodifiedFoodValues} contains the food values of the {@link #food} before the GetFoodValues event was fired.<br>
* {@link #food} contains the food in question.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
*/
public static class GetFoodValues extends FoodEvent
{
public FoodValues foodValues;
public final FoodValues unmodifiedFoodValues;
public final ItemStack food;
public GetFoodValues(@Nonnull ItemStack itemStack, FoodValues foodValues)
{
this.food = itemStack;
this.foodValues = foodValues;
this.unmodifiedFoodValues = foodValues;
}
}
/**
* Fired every time food values are retrieved to allow player-dependent control over their values.
* This event will always be preceded by {@link GetFoodValues} being fired.
*
* This event is fired in {@link FoodStats#addStats(ItemFood, ItemStack)} and in {@link AppleCoreAPI}.<br>
* <br>
* {@link #player} contains the player.<br>
* {@link #foodValues} contains the values of the {@link #food}.<br>
* {@link #unmodifiedFoodValues} contains the food values of the {@link #food} before the GetFoodValues event was fired.<br>
* {@link #food} contains the food in question.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
*/
public static class GetPlayerFoodValues extends FoodEvent
{
public FoodValues foodValues;
public final FoodValues unmodifiedFoodValues;
public final ItemStack food;
public final EntityPlayer player;
public GetPlayerFoodValues(EntityPlayer player, @Nonnull ItemStack itemStack, FoodValues foodValues)
{
this.player = player;
this.food = itemStack;
this.foodValues = foodValues;
this.unmodifiedFoodValues = foodValues;
}
}
/**
* Fired after {@link FoodStats#addStats}, containing the effects and context for the food that was eaten.
*
* This event is fired in {@link FoodStats#addStats(ItemFood, ItemStack)}.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
*/
public static class FoodEaten extends FoodEvent
{
public final FoodValues foodValues;
public final int hungerAdded;
public final float saturationAdded;
public final ItemStack food;
public final EntityPlayer player;
public FoodEaten(EntityPlayer player, @Nonnull ItemStack itemStack, FoodValues foodValues, int hungerAdded, float saturationAdded)
{
this.player = player;
this.food = itemStack;
this.foodValues = foodValues;
this.hungerAdded = hungerAdded;
this.saturationAdded = saturationAdded;
}
}
/**
* Fired when hunger/saturation is added to a player's FoodStats.
*
* This event is fired in {@link FoodStats#addStats(int, float)}.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the hunger and saturation of the FoodStats will not change.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
*/
@Cancelable
public static class FoodStatsAddition extends FoodEvent
{
public final FoodValues foodValuesToBeAdded;
public final EntityPlayer player;
public FoodStatsAddition(EntityPlayer player, FoodValues foodValuesToBeAdded)
{
this.player = player;
this.foodValuesToBeAdded = foodValuesToBeAdded;
}
}
}