-
Notifications
You must be signed in to change notification settings - Fork 753
/
Util.java
230 lines (206 loc) · 6.33 KB
/
Util.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package appeng.api;
import java.lang.reflect.InvocationTargetException;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.item.ItemStack;
import appeng.api.me.util.IAssemblerPattern;
import appeng.api.me.util.IMEInventory;
import appeng.api.me.util.IMEInventoryHandler;
import appeng.api.me.util.IMEInventoryUtil;
/**
* Returns useful stuff of various sorts to access internal features and stuff, the meat of the important stuff is accessed here...
*
* Available IMCs:
* "AppliedEnergistics", "add-grindable", "itemid,meta,itemid,meta,effort"
* "AppliedEnergistics", "blacklist-cell" "itemid[,meta]"
* "AppliedEnergistics", "blacklist-transitionplane" "itemid[,meta]"
* "AppliedEnergistics", "whitelist-transitionplane" "itemid[,meta]"
*
*/
public class Util
{
static private IAppEngApi api = null;
/**
* All future API calls should be made via this method.
* @return
*/
public static IAppEngApi getAppEngApi()
{
try {
Class c = ReflectionHelper.getClass( Util.class.getClassLoader(), "appeng.common.AppEngApi" );
api = (IAppEngApi) c.getMethod( "getInstance" ).invoke( c );
} catch ( Throwable e) {
return null;
}
return api;
}
/**
* returns the wireless terminal registry.
* @return
*/
public static IWirelessTermRegistery getWirelessTermRegistery()
{
if ( api == null ) return null;
return api.getWirelessRegistry();
}
/**
* Find an object by its serial.
* @param ser
* @return LocatedObject or null
*/
public static Object getLocateableBySerial( long ser )
{
if ( api == null ) return null;
return api.getLocateableBySerial( ser );
}
/**
* Creates a new AEItemstack.
* @param is
* @return newly generated AE Itemstack
*/
public static IAEItemStack createItemStack( ItemStack is )
{
if ( api == null ) return null;
return api.createItemStack( is );
}
/**
* Simple Wrapper of the insertion process..
* @param inv
* @param is
* @return ItemsNotInserted or null
*/
public static ItemStack addItemsToInv( IMEInventory inv, ItemStack is )
{
if ( api == null ) return null;
return api.addItemsToInv( inv, is );
}
/**
* Simple Wrapper of the extraction process
* @param inv
* @param is
* @return ItemsExtracted or null
*/
public static ItemStack extractItemsFromInv( IMEInventory inv, ItemStack is )
{
if ( api == null ) return null;
return api.extractItems( inv, is );
}
/**
* Create a new Blank ItemList
* @return new itemlist.
*/
public static IItemList createItemList()
{
if ( api == null ) return null;
return api.createItemList();
}
/**
* creates a new IMEInventoryUtil, only useful if you want to use the fancy get items by recipe functionaility.
* @param ime
* @return created InvUtil
*/
public static IMEInventoryUtil getIMEInventoryUtil( IMEInventory ime )
{
if ( api == null ) return null;
return api.getIMEInventoryUtil( ime );
}
/**
* Gets the instance of the special comparison registry ( Bees / Trees ) that sort of stuff
* @return specialComparisonRegistry
*/
public static ISpecialComparisonRegistry getSpecialComparisonRegistry()
{
if ( api == null ) return null;
return api.getSpecialComparsonRegistry();
}
/**
* Gets the instance of the external storage registry - Storage Bus
* @return externStorgeRegitry
*/
public static IExternalStorageRegistry getExternalStorageRegistry()
{
if ( api == null ) return null;
return api.getExternalStorageRegistry();
}
/**
* Gets the instance of the Cell Registry
* @return returns the cell registry
*/
public static ICellRegistry getCellRegistry()
{
if ( api == null ) return null;
return api.getCellRegistry();
}
/**
* Gets instance for the grinder recipe manager.
* @return the grinder manager instance.
*/
public static IGrinderRecipeManager getGrinderRecipeManage()
{
if ( api == null ) return null;
return api.getGrinderRecipeManage();
}
/** Is it a Blank Pattern? */
public static Boolean isBlankPattern(ItemStack i)
{
if ( api == null ) return null;
return api.isBlankPattern( i );
}
/** Is it an IAssemblerPattern? */
public static Boolean isAssemblerPattern(ItemStack i)
{
if ( api == null ) return null;
return api.isAssemblerPattern( i );
}
/** Gets the IAssemblerPattern of the Assembly Pattern. */
public static IAssemblerPattern getAssemblerPattern(ItemStack i)
{
if ( api == null ) return null;
return api.getAssemblerPattern( i );
}
/** Is it a IStorageCell, this will only return true for IStoreCells and not custom cells, you should probobly not use it unless you have a specific case. */
public static Boolean isBasicCell(ItemStack i)
{
if ( api == null ) return null;
return api.isBasicCell( i );
}
/**
* if the item is a ME Compatible Storage Cell of any type.
* @param i
* @return true, if it is a storage call.
*/
public static Boolean isCell(ItemStack i)
{
if ( api == null ) return null;
return getCellRegistry().isCellHandled( i );
}
/**
* Gets the Interface to insert/extract from the Storage Cell for the item.
* @param i
* @return newly procured cell handler.
*/
public static IMEInventoryHandler getCell(ItemStack i)
{
if ( api == null ) return null;
return getCellRegistry().getHandlerForCell( i );
}
/**
* Lets you access internal storage of IStorageCell's
* @param i
* @return only works with Basic Cells, not custom ones, suggested not to use.
*/
public static IMEInventory getBasicCell(ItemStack i)
{
if ( api == null ) return null;
return api.getBasicCell( i );
}
/**
* Lets you blast list a specific item from being stored in basic cells, this works on any mod cells that use IStorageCell as well.
* @param ItemID
* @param Meta
*/
public static void addBasicBlackList( int ItemID, int Meta )
{
if ( api == null ) return;
api.addBasicBlackList( ItemID, Meta );
}
}