-
Notifications
You must be signed in to change notification settings - Fork 497
/
DefaultActionProvider.java
59 lines (48 loc) · 1.81 KB
/
DefaultActionProvider.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
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
* <p/>
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.statements;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.BCLog;
import buildcraft.api.statements.IActionExternal;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IActionProvider;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.containers.IRedstoneStatementContainer;
import buildcraft.api.tiles.IControllable;
public class DefaultActionProvider implements IActionProvider {
@Override
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
LinkedList<IActionInternal> res = new LinkedList<IActionInternal>();
if (container instanceof IRedstoneStatementContainer) {
res.add(BuildCraftCore.actionRedstone);
}
return res;
}
@Override
public Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile) {
LinkedList<IActionExternal> res = new LinkedList<IActionExternal>();
try {
if (tile instanceof IControllable) {
for (IControllable.Mode mode : IControllable.Mode.values()) {
if (mode != IControllable.Mode.Unknown &&
((IControllable) tile).acceptsControlMode(mode)) {
res.add(BuildCraftCore.actionControl[mode.ordinal()]);
}
}
}
} catch (Throwable error) {
BCLog.logger.error("Outdated API detected, please update your mods!");
}
return res;
}
}