aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/forestry/HANDLER_FR.java
blob: c395825b33a32725524205704a4e58b029ccc3c7 (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
package gtPlusPlus.xmod.forestry;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import cpw.mods.fml.common.Optional;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.xmod.forestry.bees.items.FR_ItemRegistry;
import gtPlusPlus.xmod.forestry.bees.recipe.FR_Gregtech_Recipes;
import gtPlusPlus.xmod.forestry.bees.registry.GTPP_Bees;
import net.minecraft.block.Block;
import net.minecraft.world.World;

public class HANDLER_FR {

	public static void preInit(){
		if (LoadedMods.Forestry){
			FR_ItemRegistry.Register();
		}		
	}

	public static void Init(){
		if (LoadedMods.Forestry){
	            new GTPP_Bees();
		}
	}

	public static void postInit(){
		if (LoadedMods.Forestry){
			FR_Gregtech_Recipes.registerItems();
		}
	}

	public static boolean createBlockBreakParticles(final World world, final int x, final int y, final int z, final Block block){
		if (LoadedMods.Forestry){
			createBlockBreakParticles_INTERNAL(world, x, y, z, block);
		}
		return false;
	}

	@Optional.Method(modid = "Forestry")
	private static void createBlockBreakParticles_INTERNAL(final World world, final int x, final int y, final int z, final Block block){
		if (LoadedMods.Forestry){
			Class oClass;
			try {
				oClass = ReflectionUtils.getClass("forestry.core.proxy.ProxyCommon");
				Object oProxy = ReflectionUtils.getField(oClass, "common");				
				if (oProxy != null && oClass.isInstance(oProxy)){					
					Method mParticles = ReflectionUtils.getMethod(oClass, "addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class);					
					mParticles.invoke(oProxy, world, x, y, z, block, 0);				
				}
			}
			catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
			}
		}		
	}


}