Skip to content
Permalink
Browse files

Fiz #467 with a bit of a hack

  • Loading branch information
alcatrazEscapee committed Dec 1, 2019
1 parent ad72c98 commit 1829de694e23e78311792235125c61ce5de4314e
@@ -121,20 +121,28 @@ public static void onInitGuiPost(GuiScreenEvent.InitGuiEvent.Post event)

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onGuiButtonPress(GuiScreenEvent.ActionPerformedEvent.Post event)
public static void onGuiButtonPressPre(GuiScreenEvent.ActionPerformedEvent.Pre event)
{
if (event.getGui() instanceof GuiInventory)
{
if (event.getButton() instanceof GuiButtonPlayerInventoryTab)
{
// This should generally be true, but check just in case something has disabled it
GuiButtonPlayerInventoryTab button = (GuiButtonPlayerInventoryTab) event.getButton();
if (button.isActive())
// This is to prevent the button from immediately firing after moving (enabled is set to false then)
if (button.isActive() && button.enabled)
{
TerraFirmaCraft.getNetwork().sendToServer(new PacketSwitchPlayerInventoryTab(button.getGuiType()));
}
}
}
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onGuiButtonPressPost(GuiScreenEvent.ActionPerformedEvent.Post event)
{
if (event.getGui() instanceof GuiInventory)
{
// This is necessary to catch the resizing of the inventory gui when you open the recipe book
for (GuiButton button : event.getButtonList())
{
@@ -75,6 +75,7 @@ public void updateGuiLeft(int newGuiLeft)
x += newGuiLeft - guiLeft;
iconX += newGuiLeft - guiLeft;
guiLeft = newGuiLeft;
enabled = false;
}

public boolean isActive()
@@ -100,6 +101,7 @@ public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float part
// The icon
drawScaledCustomSizeModalRect(iconX, iconY, iconU, iconV, 32, 32, 16, 16, 256, 256);
mouseDragged(mc, mouseX, mouseY);
enabled = true;
}
}
}

0 comments on commit 1829de6

Please sign in to comment.
You can’t perform that action at this time.