2014-12-15 00:11:48 +00:00
|
|
|
package com.cricketcraft.chisel.client.gui;
|
2014-10-27 16:26:14 -04:00
|
|
|
|
2015-01-07 23:36:27 -05:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-10-27 16:26:14 -04:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2015-01-08 02:06:12 -05:00
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
2014-10-27 16:26:14 -04:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2015-01-07 23:36:27 -05:00
|
|
|
import net.minecraft.inventory.Slot;
|
2014-10-27 16:26:14 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-01-07 23:36:27 -05:00
|
|
|
import net.minecraft.util.StatCollector;
|
2014-12-14 20:05:39 +00:00
|
|
|
|
2014-10-27 16:26:14 -04:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
2014-12-15 00:11:48 +00:00
|
|
|
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
|
|
|
|
|
import com.cricketcraft.chisel.inventory.ContainerAutoChisel;
|
2015-01-09 01:50:32 -05:00
|
|
|
import com.cricketcraft.chisel.inventory.ContainerAutoChisel.SlotAutoChisel;
|
|
|
|
|
import com.google.common.base.Strings;
|
2015-01-07 23:36:27 -05:00
|
|
|
import com.google.common.collect.Lists;
|
2014-12-15 00:11:48 +00:00
|
|
|
|
2014-10-27 16:26:14 -04:00
|
|
|
public class GuiAutoChisel extends GuiContainer {
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
|
2014-10-27 16:26:14 -04:00
|
|
|
|
2015-01-09 01:50:32 -05:00
|
|
|
private TileEntityAutoChisel autochisel;
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
|
|
|
|
|
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
|
2015-01-09 01:50:32 -05:00
|
|
|
autochisel = tileEntityAutoChisel;
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
2014-10-27 16:26:14 -04:00
|
|
|
|
2015-01-07 23:36:27 -05:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Override
|
|
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
|
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
|
|
|
|
|
|
|
|
|
int x = (this.width - this.xSize) / 2;
|
|
|
|
|
int y = (this.height - this.ySize) / 2;
|
|
|
|
|
|
|
|
|
|
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
|
|
|
|
|
if (mouseInside(slot, mouseX - x, mouseY - y)) {
|
2015-01-09 01:50:32 -05:00
|
|
|
if (slot instanceof SlotAutoChisel) {
|
|
|
|
|
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
|
|
|
|
|
if (!Strings.isNullOrEmpty(tt)) {
|
|
|
|
|
this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal(tt)), mouseX - x, mouseY - y);
|
|
|
|
|
}
|
2015-01-07 23:36:27 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-08 02:06:12 -05:00
|
|
|
RenderHelper.enableGUIStandardItemLighting();
|
2015-01-07 23:36:27 -05:00
|
|
|
}
|
2015-01-09 01:50:32 -05:00
|
|
|
|
2015-01-07 23:36:27 -05:00
|
|
|
private boolean mouseInside(Slot slot, int x, int y) {
|
|
|
|
|
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16 && y >= slot.yDisplayPosition && y <= slot.yDisplayPosition + 16;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@Override
|
|
|
|
|
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
|
this.mc.renderEngine.bindTexture(gui);
|
|
|
|
|
int x = (width - xSize) / 2;
|
|
|
|
|
int y = (height - ySize) / 2;
|
|
|
|
|
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
|
|
|
|
}
|
2014-10-27 16:26:14 -04:00
|
|
|
}
|