mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +00:00
Fix tab position when NEI is installed and not hidden.
This commit is contained in:
1 parent
c587a827c8
commit
150fb8b3f4
1 file changed
+45
-8
@@ -1,15 +1,18 @@
|
||||
package tconstruct.client.tabs;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TabRegistry
|
||||
{
|
||||
@@ -35,10 +38,7 @@ public class TabRegistry
|
||||
int ySize = 166;
|
||||
int guiLeft = (event.gui.width - xSize) / 2;
|
||||
int guiTop = (event.gui.height - ySize) / 2;
|
||||
if (!mc.thePlayer.getActivePotionEffects().isEmpty())
|
||||
{
|
||||
guiLeft += 60;
|
||||
}
|
||||
guiLeft += getPotionOffset();
|
||||
|
||||
updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class);
|
||||
addTabsToList(event.gui.buttonList);
|
||||
@@ -82,4 +82,41 @@ public class TabRegistry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPotionOffset()
|
||||
{
|
||||
// If at least one potion is active...
|
||||
if (!mc.thePlayer.getActivePotionEffects().isEmpty())
|
||||
{
|
||||
if (Loader.isModLoaded("NotEnoughItems"))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check whether NEI is hidden and enabled
|
||||
Class<?> c = Class.forName("codechicken.nei.NEIClientConfig");
|
||||
Object hidden = c.getMethod("isHidden").invoke(null);
|
||||
Object enabled = c.getMethod("isEnabled").invoke(null);
|
||||
if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean)
|
||||
{
|
||||
if ((Boolean)hidden || !((Boolean)enabled))
|
||||
{
|
||||
// If NEI is disabled or hidden, offset the tabs by 60
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If NEI is not installed, offset the tabs
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
|
||||
// No potions, no offset needed
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user