/
RegisterEvent.java
37 lines (31 loc) · 998 Bytes
/
RegisterEvent.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
package knightminer.inspirations.library.event;
import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Base class for registering things to the Inspirations Registry
* @param <T> Class being registered
*/
@Cancelable
public abstract class RegisterEvent<T> extends Event {
private final T recipe;
public RegisterEvent(T recipe) {
this.recipe = recipe;
}
public T getRecipe() {
return recipe;
}
/** Returns true on success, false if cancelled */
public boolean fire() {
return !MinecraftForge.EVENT_BUS.post(this);
}
/**
* Class for registering cauldron recipes. May be many different cauldron recipe types
*/
public static class RegisterCauldronRecipe extends RegisterEvent<ICauldronRecipe> {
public RegisterCauldronRecipe(ICauldronRecipe recipe) {
super(recipe);
}
}
}