Exemplo n.º 1
0
 @Override
 public void tryUseTConstruct() {
   try {
     Class tabRegistry = Class.forName("tconstruct.client.tabs.TabRegistry");
     Class abstractTab = Class.forName("tconstruct.client.tabs.AbstractTab");
     Method registerTab = tabRegistry.getMethod("registerTab", abstractTab);
     updateTab = tabRegistry.getMethod("updateTabValues", int.class, int.class, Class.class);
     addTabs = tabRegistry.getMethod("addTabsToList", List.class);
     registerTab.invoke(
         null, Class.forName("mods.battlegear2.client.gui.controls.EquipGearTab").newInstance());
     if (Battlegear.debug) {
       registerTab.invoke(
           null, Class.forName("mods.battlegear2.client.gui.controls.SigilTab").newInstance());
     }
   } catch (Exception e) {
     return;
   }
   tconstructEnabled = true;
 }
Exemplo n.º 2
0
 @Override
 public void tryUseDynamicLight(EntityPlayer player, ItemStack stack) {
   if (player == null && stack == null) {
     dynLightPlayerMod =
         Loader.instance().getIndexedModList().get("DynamicLights_thePlayer").getMod();
     try {
       if (dynLightPlayerMod != null) {
         dynLightFromItemStack =
             dynLightPlayerMod
                 .getClass()
                 .getDeclaredMethod("getLightFromItemStack", ItemStack.class);
         dynLightFromItemStack.setAccessible(true);
         refresh =
             Class.forName("mods.battlegear2.client.utils.DualHeldLight")
                 .getMethod("refresh", EntityPlayer.class, int.class, int.class);
       }
     } catch (Exception e) {
       return;
     }
   }
   if (dynLightFromItemStack != null && refresh != null) {
     if (!ItemStack.areItemStacksEqual(stack, heldCache)) {
       try {
         int lightNew = Integer.class.cast(dynLightFromItemStack.invoke(dynLightPlayerMod, stack));
         int lightOld =
             Integer.class.cast(dynLightFromItemStack.invoke(dynLightPlayerMod, heldCache));
         if (lightNew != lightOld) {
           refresh.invoke(null, player, lightNew, lightOld);
         }
       } catch (Exception e) {
         return;
       }
       heldCache = stack;
     }
   }
 }