blob: 87967b75b5c9ca32276f42fa04040257e76996d3 (
plain)
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
|
package gtPlusPlus.core.slots;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
public class SlotToolBox extends SlotGtTool {
private static final AutoMap<Class> mSupportedCustomTools = new AutoMap<Class>();
static {
//Look for Supported custom tool types
Class temp;
//IHL Pumps
temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//IC2 Electrics
temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//IC2 Boxables
temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//Tinkers Tools
temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//BattleGear Weapons
temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//OpenMods
String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"};
for (String t : OpenModsContent) {
temp = ReflectionUtils.getClass(t);
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
}
//GC Wrench
temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
//EIO
String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"};
for (String t : EioContent) {
temp = ReflectionUtils.getClass(t);
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
}
//Forestry
temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool");
if (temp != null) {
mSupportedCustomTools.put(temp);
temp = null;
}
}
public SlotToolBox(final IInventory base, final int x, final int y, final int z) {
super(base, x, y, z);
}
@Override
public boolean isItemValid(final ItemStack itemstack) {
return isItemValid_STATIC(itemstack);
}
public static boolean isItemValid_STATIC(final ItemStack itemstack) {
if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) {
Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool.");
return true;
}
for (Class C : mSupportedCustomTools) {
if (C.isInstance(itemstack.getItem())) {
return true;
}
}
Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool.");
return false;
}
}
|