blob: 74a627b2c5120fd5affa3cfab90736596642ea74 (
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
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
|
package gtPlusPlus.xmod.forestry.trees;
import cpw.mods.fml.common.Optional;
import gregtech.api.enums.OrePrefixes;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
public class TreefarmManager {
public static boolean isHumusLoaded = false;
public static boolean isForestryLogsLoaded = false;
public static boolean isForestryFenceLoaded = false;
public static boolean isForestrySaplingsLoaded = false;
public static boolean isForestryLeavesLoaded = false;
public static Block blockHumus;
public static boolean isForestryValid(){
if (!LoadedMods.Forestry){
return false;
}
if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
isHumusLoaded = true;
}
if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){
isForestryLogsLoaded = true;
}
if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){
isForestryFenceLoaded = true;
}
if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){
isForestrySaplingsLoaded = true;
}
if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){
isForestryLeavesLoaded = true;
}
return true;
}
@Optional.Method(modid = "Forestry")
public static Block getHumus(){
if(blockHumus != null){
return blockHumus;
}
else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){
try {
final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil");
final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1);
if (humusClass != null){
blockHumus = Block.getBlockFromItem(humusStack.getItem());
return Block.getBlockFromItem(humusStack.getItem());
}
} catch (final ClassNotFoundException e) {}
}
return null;
}
public static boolean isWoodLog(final Block log){
final String tTool = log.getHarvestTool(0);
if ((log == Blocks.log) || (log == Blocks.log2)){
return true;
}
//Forestry/General Compat
if (log.getClass().getName().toLowerCase().contains("blocklog")){
return true;
}
//IC2 Rubber Tree Compat
if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){
return true;
}
return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true);
}
public static boolean isLeaves(final Block log){
if (log.getUnlocalizedName().toLowerCase().contains("leaf")){
return true;
}
if (log.getUnlocalizedName().toLowerCase().contains("leaves")){
return true;
}
if (log.getLocalizedName().toLowerCase().contains("leaf")){
return true;
}
if (log.getLocalizedName().toLowerCase().contains("leaves")){
return true;
}
return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves);
}
public static boolean isSapling(final Block log){
if (log != null){
if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){
Utils.LOG_INFO(""+log.getLocalizedName());
}
if (log.getLocalizedName().toLowerCase().contains("sapling")){
Utils.LOG_INFO(""+log.getLocalizedName());
return true;
}
}
return OrePrefixes.sapling.contains(new ItemStack(log, 1));
}
public static boolean isDirtBlock(final Block dirt){
return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false))));
}
public static boolean isFenceBlock(final Block fence){
return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false))));
}
public static boolean isAirBlock(final Block air){
if (air.getLocalizedName().toLowerCase().contains("air")){
return true;
}
if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){
return true;
}
//Utils.LOG_INFO("Found "+air.getLocalizedName());
return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false));
}
/*public static boolean isSaplingBlock(Block sapling){
return (sapling == Blocks.sapling ? true : (sapling == Blocks.))
}*/
}
|