forked from wormzjl/ModularMachinery
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathRecipeEvent.java
More file actions
63 lines (54 loc) · 2.05 KB
/
Copy pathRecipeEvent.java
File metadata and controls
63 lines (54 loc) · 2.05 KB
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
package github.kasuminova.mmce.common.event.recipe;
import crafttweaker.annotations.ZenRegister;
import github.kasuminova.mmce.common.event.machine.IEventHandler;
import github.kasuminova.mmce.common.event.machine.MachineEvent;
import hellfirepvp.modularmachinery.common.crafting.ActiveMachineRecipe;
import hellfirepvp.modularmachinery.common.crafting.helper.RecipeCraftingContext;
import hellfirepvp.modularmachinery.common.machine.RecipeThread;
import hellfirepvp.modularmachinery.common.tiles.base.TileMultiblockMachineController;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import java.util.List;
@ZenRegister
@ZenClass("mods.modularmachinery.RecipeEvent")
public class RecipeEvent extends MachineEvent {
private final ActiveMachineRecipe activeRecipe;
private final RecipeCraftingContext context;
private final RecipeThread recipeThread;
public RecipeEvent(TileMultiblockMachineController controller, RecipeThread recipeThread, RecipeCraftingContext context) {
super(controller);
this.activeRecipe = context.getActiveRecipe();
this.context = context;
this.recipeThread = recipeThread;
}
@ZenGetter("activeRecipe")
public ActiveMachineRecipe getActiveRecipe() {
return activeRecipe;
}
public RecipeCraftingContext getContext() {
return context;
}
public RecipeThread getRecipeThread() {
return recipeThread;
}
@Override
public void postCrTEvent() {
if (activeRecipe == null || activeRecipe.getRecipe() == null) {
return;
}
super.postCrTEvent();
if (isCanceled()) {
return;
}
List<IEventHandler<RecipeEvent>> handlers = activeRecipe.getRecipe().getRecipeEventHandlers().get(getClass());
if (handlers == null) {
return;
}
for (IEventHandler<RecipeEvent> handler : handlers) {
handler.invoke(this);
if (isCanceled()) {
break;
}
}
}
}