From 3b18aea1576626bb5d1b7c9747055797a38912f4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 8 Aug 2018 14:54:38 +0200 Subject: [PATCH] Move the GuiItemStackButton to live with the rest of the gui classes and improved error message handling --- .../com/minelittlepony/gui/IconicButton.java | 31 +++ .../java/com/minelittlepony/gui/Button.java | 4 +- .../voxelmodpack/hdskins/gui/GLWindow.java | 2 +- .../hdskins/gui/GuiItemStackButton.java | 30 --- .../voxelmodpack/hdskins/gui/GuiSkins.java | 221 +++++++++--------- .../hdskins/mixin/MixinGuiMainMenu.java | 7 +- .../hdskins/gui/GuiSkinsMineLP.java | 10 +- 7 files changed, 154 insertions(+), 151 deletions(-) create mode 100644 src/common/java/com/minelittlepony/gui/IconicButton.java delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java diff --git a/src/common/java/com/minelittlepony/gui/IconicButton.java b/src/common/java/com/minelittlepony/gui/IconicButton.java new file mode 100644 index 00000000..418b7f87 --- /dev/null +++ b/src/common/java/com/minelittlepony/gui/IconicButton.java @@ -0,0 +1,31 @@ +package com.minelittlepony.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class IconicButton extends Button { + + private ItemStack itemStack = ItemStack.EMPTY; + + public IconicButton(int x, int y, IGuiAction callback) { + super(x, y, 20, 20, "", callback); + } + + public IconicButton setIcon(ItemStack stack) { + itemStack = stack; + return this; + } + + public IconicButton setIcon(ItemStack stack, int colour) { + Items.LEATHER_LEGGINGS.setColor(stack, colour); + return setIcon(stack); + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + super.drawButton(mc, mouseX, mouseY, partialTicks); + + mc.getRenderItem().renderItemIntoGUI(itemStack, x + 2, y + 2); + } +} diff --git a/src/hdskins/java/com/minelittlepony/gui/Button.java b/src/hdskins/java/com/minelittlepony/gui/Button.java index 7963ca56..da1392a4 100644 --- a/src/hdskins/java/com/minelittlepony/gui/Button.java +++ b/src/hdskins/java/com/minelittlepony/gui/Button.java @@ -9,13 +9,13 @@ import net.minecraft.client.gui.GuiButton; public class Button extends GuiButton implements IActionable, IGuiTooltipped { - private IGuiAction