Java Code Examples for cpw.mods.fml.relauncher.ReflectionHelper

The following examples show how to use cpw.mods.fml.relauncher.ReflectionHelper. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ehacks-pro   Source File: Nan0EventRegistar.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void register(EventBus bus, Object target) {
    ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners");
    Map<Object, ModContainer> listenerOwners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listenerOwners");
    if (listeners.containsKey(target)) {
        return;
    }
    ModContainer activeModContainer = Loader.instance().getMinecraftModContainer();
    listenerOwners.put(target, activeModContainer);
    ReflectionHelper.setPrivateValue(EventBus.class, bus, listenerOwners, "listenerOwners");
    Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes();
    for (Method method : target.getClass().getMethods()) {
        for (Class<?> cls : supers) {
            try {
                Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes());
                if (real.isAnnotationPresent(SubscribeEvent.class)) {
                    Class<?>[] parameterTypes = method.getParameterTypes();
                    Class<?> eventType = parameterTypes[0];
                    register(bus, eventType, target, method, activeModContainer);
                    break;
                }
            } catch (NoSuchMethodException ignored) {
            }
        }
    }
}
 
Example 2
Source Project: ehacks-pro   Source File: Nan0EventRegistar.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void register(EventBus bus, Class<?> eventType, Object target, Method method, ModContainer owner) {
    try {
        int busID = ReflectionHelper.getPrivateValue(EventBus.class, bus, "busID");
        ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners");
        Constructor<?> ctr = eventType.getConstructor();
        ctr.setAccessible(true);
        Event event = (Event) ctr.newInstance();
        ASMEventHandler listener = new ASMEventHandler(target, method, owner);
        event.getListenerList().register(busID, listener.getPriority(), listener);
        ArrayList<IEventListener> others = listeners.get(target);
        if (others == null) {
            others = new ArrayList<>();
            listeners.put(target, others);
            ReflectionHelper.setPrivateValue(EventBus.class, bus, listeners, "listeners");
        }
        others.add(listener);
    } catch (Exception e) {
    }
}
 
Example 3
Source Project: Et-Futurum   Source File: EntityRabbit.java    License: The Unlicense 6 votes vote down vote up
public EntityRabbit(World world) {
	super(world);
	moveType = EntityRabbit.EnumMoveType.HOP;
	carrotTicks = 0;
	setSize(0.4F, 0.5F);
	ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitJumpHelper(this), "jumpHelper", "field_70767_i");
	ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitMoveHelper(), "moveHelper", "field_70765_h");
	getNavigator().setAvoidsWater(true);
	//		navigator.func_179678_a(2.5F);
	tasks.addTask(1, new EntityAISwimming(this));
	tasks.addTask(1, new EntityRabbit.AIPanic(1.33D));
	tasks.addTask(2, new EntityAIMate(this, 0.8D));
	tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.carrot, false));
	tasks.addTask(5, new EntityRabbit.AIRaidFarm());
	tasks.addTask(5, new EntityAIWander(this, 0.6D));
	tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F));
	tasks.addTask(4, new EntityAIAvoidEntity(this, EntityWolf.class, 16.0F, 1.33D, 1.33D));
	tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 0.8D, 1.33D));
	setMovementSpeed(0.0D);
}
 
Example 4
Source Project: Et-Futurum   Source File: EntityTippedArrow.java    License: The Unlicense 6 votes vote down vote up
@Override
public void onCollideWithPlayer(EntityPlayer player) {
	boolean inGround = false;
	try {
		inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
	} catch (Exception e) {
	}

	if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
		boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;

		ItemStack stack = new ItemStack(ModItems.tipped_arrow);
		TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());

		if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
			flag = false;

		if (flag) {
			playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			player.onItemPickup(this, 1);
			setDead();
		}
	}
}
 
Example 5
Source Project: Et-Futurum   Source File: RabbitFoot.java    License: The Unlicense 6 votes vote down vote up
@SuppressWarnings("unchecked")
public RabbitFoot() {
	setTextureName("rabbit_foot");
	setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot"));
	setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null);

	if (EtFuturum.enableRabbit)
		try {
			Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l");
			f.setAccessible(true);
			HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null);
			potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3");

			Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m");
			f2.setAccessible(true);
			HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null);
			potionAmplifiers.put(Potion.jump.getId(), "5");

			Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N");
			f3.setAccessible(true);
			f3.set(Potion.jump, 0x22FF4C);
		} catch (Exception e) {
		}
}
 
Example 6
Source Project: NEI-Integration   Source File: ChestLootDumper.java    License: MIT License 6 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    Map<String, ChestGenHooks> lootTables = ReflectionHelper.getPrivateValue(ChestGenHooks.class, null, "chestInfo");
    List<String> names = new ArrayList<String>();
    names.addAll(lootTables.keySet());
    Collections.sort(names);
    
    for (String name : names) {
        List<WeightedRandomChestContent> contents = ReflectionHelper.getPrivateValue(ChestGenHooks.class, lootTables.get(name), "contents");
        
        for (WeightedRandomChestContent w : contents) {
            String displayName;
            try {
                displayName = w.theItemId.getDisplayName();
            } catch (Exception ex) {
                displayName = "-";
            }
            list.add(new String[] { name, w.theItemId.toString(), displayName, Item.itemRegistry.getNameForObject(w.theItemId.getItem()), String.valueOf(w.itemWeight) });
        }
    }
    
    return list;
}
 
Example 7
Source Project: NEI-Integration   Source File: TileEntityDumper.java    License: MIT License 6 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    Map<Class, String> classToNameMap = ReflectionHelper.getPrivateValue(TileEntity.class, null, "field_145853_j", "classToNameMap");
    List<Class> classes = new ArrayList<Class>();
    classes.addAll(classToNameMap.keySet());
    Collections.sort(classes, new Comparator<Class>() {
        @Override
        public int compare(Class o1, Class o2) {
            if (o1 == null || o2 == null) {
                return 0;
            }
            return o1.getName().compareTo(o2.getName());
        }
    });
    
    for (Class clazz : classes) {
        if (clazz != null) {
            list.add(new String[] { clazz.getName(), classToNameMap.get(clazz) });
        }
    }
    
    return list;
}
 
Example 8
Source Project: NEI-Integration   Source File: DimensionDumper.java    License: MIT License 6 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    List<Integer> ids = new ArrayList<Integer>();
    ids.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs()));
    Collections.sort(ids);
    
    for (int id : ids) {
        int providerId = DimensionManager.getProviderType(id);
        Map<Integer, Class> providers = ReflectionHelper.getPrivateValue(DimensionManager.class, null, "providers");
        Class providerClass = providers.get(providerId);
        list.add(new String[] { String.valueOf(id), String.valueOf(providerId), providerClass.getName() });
    }
    
    return list;
}
 
Example 9
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, int x, int y, int z, Block block, TileEntity te){
    if(tileEntityClassToNameMapping == null) {
        try {
            tileEntityClassToNameMapping = (Map)ReflectionHelper.findField(TileEntity.class, "field_145853_j", "classToNameMap").get(null);
        } catch(Exception e) {
            Log.error("[BlockTrackEntryInventory.class] Uhm reflection failed here!");
            e.printStackTrace();
        }
    }
    if(te instanceof TileEntityChest) {
        TileEntityChest chest = (TileEntityChest)te;
        if(chest.adjacentChestXNeg != null || chest.adjacentChestZNeg != null) return false;
    }
    return te != null && !invBlackList.contains(tileEntityClassToNameMapping.get(te.getClass())) && te instanceof IInventory && ((IInventory)te).getSizeInventory() > 0 && !MinecraftForge.EVENT_BUS.post(new InventoryTrackEvent(te));
}
 
Example 10
Source Project: ehacks-pro   Source File: Debug.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static List<TileEntity> getNearTileEntities() {
    ArrayList<TileEntity> out = new ArrayList<>();
    IChunkProvider chunkProvider = getWorld().getChunkProvider();
    if (chunkProvider instanceof ChunkProviderClient) {
        List<Chunk> chunks = ReflectionHelper.getPrivateValue(ChunkProviderClient.class, (ChunkProviderClient) chunkProvider, Mappings.chunkListing);
        chunks.forEach((chunk) -> {
            chunk.chunkTileEntityMap.values().stream().filter((entityObj) -> !(!(entityObj instanceof TileEntity))).forEachOrdered((entityObj) -> {
                out.add((TileEntity) entityObj);
            });
        });
    }
    return out;
}
 
Example 11
Source Project: ehacks-pro   Source File: NoLimitClear.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onModuleEnabled() {
    try {
        Class.forName("powercrystals.minefactoryreloaded.net.ServerPacketHandler");
        int count = 0;
        IChunkProvider chunkProvider = Wrapper.INSTANCE.world().getChunkProvider();
        if (chunkProvider instanceof ChunkProviderClient) {
            ChunkProviderClient clientProvider = (ChunkProviderClient) chunkProvider;
            List<Chunk> chunks = ReflectionHelper.getPrivateValue(ChunkProviderClient.class, clientProvider, Mappings.chunkListing);
            for (Chunk chunk : chunks) {
                for (Object entityObj : chunk.chunkTileEntityMap.values()) {
                    if (!(entityObj instanceof TileEntity)) {
                        return;
                    }
                    TileEntity entity = (TileEntity) entityObj;
                    if (entity instanceof IInventory) {
                        IInventory inv = (IInventory) entity;
                        TileEntity ent = entity;
                        for (int i = 0; i < inv.getSizeInventory(); i++) {
                            setSlot(i, ent.xCoord, ent.yCoord, ent.zCoord);
                        }
                        count++;
                    }
                }
            }
        }
        InteropUtils.log("Cleared " + String.valueOf(count) + " containers", this);
        this.off();
    } catch (Exception ex) {
        this.off();
    }
}
 
Example 12
Source Project: ehacks-pro   Source File: FastClick.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    if (Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed()) {
        try {
            Method m = ReflectionHelper.findMethod(Minecraft.class, Wrapper.INSTANCE.mc(), new String[]{"func_147116_af"}, (Class[]) null);
            m.invoke(Wrapper.INSTANCE.mc());
        } catch (Exception e) {
        }
    }
}
 
Example 13
Source Project: ehacks-pro   Source File: FastPlace.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    if (Wrapper.INSTANCE.mcSettings().keyBindUseItem.getIsKeyPressed()) {
        try {
            Method m = ReflectionHelper.findMethod(Minecraft.class, Wrapper.INSTANCE.mc(), new String[]{"func_147121_ag"}, (Class[]) null);
            m.invoke(Wrapper.INSTANCE.mc());
        } catch (Exception e) {
        }
    }
}
 
Example 14
Source Project: ehacks-pro   Source File: Events.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onGuiScreenDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
    if (event.gui instanceof GuiMainMenu) {
        GuiMainMenu mainMenu = (GuiMainMenu) event.gui;
        ReflectionHelper.setPrivateValue(GuiMainMenu.class, mainMenu, "Fucked by radioegor146", Mappings.splashText);
    }
}
 
Example 15
Source Project: ehacks-pro   Source File: Mappings.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static boolean isMCP() {
    try {
        return ReflectionHelper.findField(Minecraft.class, new String[]{"theMinecraft"}) != null;
    } catch (Exception ex) {
        return false;
    }
}
 
Example 16
Source Project: Et-Futurum   Source File: ContainerAnvil.java    License: The Unlicense 5 votes vote down vote up
public ContainerAnvil(EntityPlayer player, World world, int x, int y, int z) {
	super(player.inventory, world, x, y, z, player);
	this.player = player;
	this.x = x;
	this.y = y;
	this.z = z;
	this.world = world;

	inputSlots = ReflectionHelper.getPrivateValue(ContainerRepair.class, this, "inputSlots", "field_82853_g");
	outputSlot = ReflectionHelper.getPrivateValue(ContainerRepair.class, this, "outputSlot", "field_82852_f");
}
 
Example 17
Source Project: Et-Futurum   Source File: GuiAnvil.java    License: The Unlicense 5 votes vote down vote up
public GuiAnvil(EntityPlayer player, World world, int x, int y, int z) {
	super(player.inventory, world, x, y, z);

	ContainerAnvil container = new ContainerAnvil(player, world, x, y, z);
	ReflectionHelper.setPrivateValue(GuiRepair.class, this, container, "field_147092_v");
	inventorySlots = container;
}
 
Example 18
Source Project: Et-Futurum   Source File: EtFuturum.java    License: The Unlicense 5 votes vote down vote up
private void setFinalField(Class<?> cls, Object obj, Object newValue, String... fieldNames) {
	try {
		Field field = ReflectionHelper.findField(cls, fieldNames);
		field.setAccessible(true);

		Field modifiersField = Field.class.getDeclaredField("modifiers");
		modifiersField.setAccessible(true);
		modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

		field.set(obj, newValue);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 19
Source Project: Et-Futurum   Source File: ClientProxy.java    License: The Unlicense 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void registerEntityRenderers() {
	if (EtFuturum.enableArmourStand)
		RenderingRegistry.registerEntityRenderingHandler(EntityArmourStand.class, new ArmourStandRenderer());
	if (EtFuturum.enableEndermite)
		RenderingRegistry.registerEntityRenderingHandler(EntityEndermite.class, new EndermiteRenderer());
	if (EtFuturum.enableRabbit)
		RenderingRegistry.registerEntityRenderingHandler(EntityRabbit.class, new RabbitRenderer());
	if (EtFuturum.enableLingeringPotions) {
		RenderingRegistry.registerEntityRenderingHandler(EntityLingeringPotion.class, new LingeringPotionRenderer());
		RenderingRegistry.registerEntityRenderingHandler(EntityLingeringEffect.class, new LingeringEffectRenderer());
	}
	if (EtFuturum.enableVillagerZombies)
		RenderingRegistry.registerEntityRenderingHandler(EntityZombieVillager.class, new VillagerZombieRenderer());
	if (EtFuturum.enableDragonRespawn)
		RenderingRegistry.registerEntityRenderingHandler(EntityPlacedEndCrystal.class, new PlacedEndCrystalRenderer());
	if (EtFuturum.enablePlayerSkinOverlay) {
		TextureManager texManager = Minecraft.getMinecraft().renderEngine;
		File fileAssets = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "fileAssets", "field_110446_Y", " field_110607_c");
		File skinFolder = new File(fileAssets, "skins");
		MinecraftSessionService sessionService = Minecraft.getMinecraft().func_152347_ac();
		ReflectionHelper.setPrivateValue(Minecraft.class, Minecraft.getMinecraft(), new NewSkinManager(Minecraft.getMinecraft().func_152342_ad(), texManager, skinFolder, sessionService), "field_152350_aA");

		RenderManager.instance.entityRenderMap.put(EntityPlayer.class, new NewRenderPlayer());
	}
	if (EtFuturum.enableShearableGolems)
		RenderingRegistry.registerEntityRenderingHandler(EntityNewSnowGolem.class, new NewSnowGolemRenderer());
}
 
Example 20
Source Project: LegacyJavaFixer   Source File: LegacyJavaFixer.java    License: MIT License 5 votes vote down vote up
SortReplacement()
{
    try 
    {
        wrapperCls = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper", false, SortReplacement.class.getClassLoader());
        wrapperField = wrapperCls.getDeclaredField("sortIndex");
        wrapperField.setAccessible(true);
        tweakSorting = ReflectionHelper.getPrivateValue(CoreModManager.class, null, "tweakSorting");
    }
    catch (Exception e)
    {
        e.printStackTrace();
        Throwables.propagate(e);
    }
}
 
Example 21
Source Project: NEI-Integration   Source File: EntityDumper.java    License: MIT License 5 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    List<Integer> ids = new ArrayList<Integer>();
    ids.addAll(EntityList.IDtoClassMapping.keySet());
    Collections.sort(ids);
    
    for (int id : ids) {
        list.add(new String[] { GLOBAL, String.valueOf(id), EntityList.getStringFromID(id), EntityList.getClassFromID(id).getName() });
    }
    
    ListMultimap<ModContainer, EntityRegistration> modEntities = ReflectionHelper.getPrivateValue(EntityRegistry.class, EntityRegistry.instance(), "entityRegistrations");
    
    for (Entry<ModContainer, EntityRegistration> e : modEntities.entries()) {
        EntityRegistration er = e.getValue();
        list.add(new String[] { e.getKey().getModId(), String.valueOf(er.getModEntityId()), e.getKey().getModId() + "." + er.getEntityName(), er.getEntityClass().getName() });
    }
    
    Collections.sort(list, new Comparator<String[]>() {
        @Override
        public int compare(String[] s1, String[] s2) {
            if (s1[0].equals(GLOBAL) && !s1[0].equals(s2[0])) {
                return -1;
            }
            int i = s1[0].compareTo(s2[0]);
            if (i != 0) {
                return i;
            }
            return Integer.compare(Integer.valueOf(s1[1]), Integer.valueOf(s2[1]));
        }
    });
    
    return list;
}
 
Example 22
@SubscribeEvent
public void onCreeperSpawn(EntityJoinWorldEvent event){
    if(event.entity instanceof EntityCreeper) {
        ((EntityCreeper)event.entity).explosionRadius = 0;
        try {
            Field field = ReflectionHelper.findField(EntityCreeper.class, "field_82225_f", "fuseTime");
            field.set(event.entity, 80);
        } catch(Throwable e) {
            Log.warn("Reflection on Creeper fuseTime failed!");
            e.printStackTrace();
        }
    }
}
 
Example 23
public BlockLogTainted()
{
    super();
    setCreativeTab(Forbidden.tab);
    setStepSound(ConfigBlocks.blockTaint.stepSound);
    try {
        Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J");
        mat.set(this, Config.taintMaterial);
    } catch (Exception e){
        e.printStackTrace();
    }
    this.setHarvestLevel("axe", 0);
}
 
Example 24
public BlockLeavesTainted()
{
    super();
    setCreativeTab(Forbidden.tab);
    setLightOpacity(0);
    setHardness(0.2F);
    setStepSound(ConfigBlocks.blockTaint.stepSound);
    try {
        Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J");
        mat.set(this, Config.taintMaterial);
    } catch (Exception e){
        e.printStackTrace();
    }
}
 
Example 25
public BlockSaplingTainted()
{
    super();
    setCreativeTab(Forbidden.tab);
    setStepSound(ConfigBlocks.blockTaint.stepSound);
    try {
        Field mat = ReflectionHelper.findField(Block.class, "blockMaterial", "field_149764_J");
        mat.set(this, Config.taintMaterial);
    } catch (Exception e){
        e.printStackTrace();
    }
}
 
Example 26
Source Project: PneumaticCraft   Source File: HackableWitch.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean afterHackTick(Entity entity){
    if(attackTimer == null) attackTimer = ReflectionHelper.findField(EntityWitch.class, "field_82200_e", "witchAttackTimer");
    try {
        attackTimer.set(entity, 20);
        ((EntityWitch)entity).setAggressive(true);
        return true;
    } catch(Exception e) {
        Log.warning("Reflection failed on HackableWitch:");
        e.printStackTrace();
        return false;
    }
}
 
Example 27
Source Project: PneumaticCraft   Source File: EntityDrone.java    License: GNU General Public License v3.0 5 votes vote down vote up
public EntityDrone(World world){
    super(world);
    setSize(0.7F, 0.35F);
    ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityPathNavigateDrone(this, world), "navigator", "field_70699_by");
    ReflectionHelper.setPrivateValue(EntityLiving.class, this, new DroneMoveHelper(this), "moveHelper", "field_70765_h");
    tasks.addTask(1, chargeAI = new DroneGoToChargingStation(this));
}
 
Example 28
Source Project: PneumaticCraft   Source File: DramaSplash.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run(){
    try {
        if(getAsieSplashMethod == null) {
            Class okuTickHandler = Class.forName("okushama.drama.TickHandlerClient");
            okuTickHandlerInstance = okuTickHandler.newInstance();
            getAsieSplashMethod = ReflectionHelper.findMethod(okuTickHandler, okuTickHandlerInstance, new String[]{"asieSplash"});
        }
        cachedLine = (String)getAsieSplashMethod.invoke(okuTickHandlerInstance);
    } catch(Exception e) {
        Log.warning("Reflection failed on the Drama Splash getter!");
        e.printStackTrace();
        failed = true;
    }
}
 
Example 29
Source Project: PneumaticCraft   Source File: IGWMod.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void preInit(){
    try {
        int minorVersion = Integer.parseInt((String)ReflectionHelper.getPrivateValue(Constants.class, null, "MINOR"));
        if(minorVersion < 7) FMLCommonHandler.instance().bus().register(this);
    } catch(Throwable e) {
        e.printStackTrace();
    }
}
 
Example 30
public boolean isDigging(){
    if(isDigging == null) isDigging = ReflectionHelper.findField(ItemInWorldManager.class, "field_73088_d", "isDestroyingBlock");
    try {
        return isDigging.getBoolean(this);
    } catch(Exception e) {
        Log.error("Drone FakePlayerItemInWorldManager failed with reflection (Digging)!");
        e.printStackTrace();
        return true;
    }
}