2015-08-18 20:40:55 -04:00
|
|
|
package team.chisel.client.gui;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-18 15:58:13 -05:00
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2014-04-21 19:13:15 +01:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2014-09-11 02:13:41 +02:00
|
|
|
import net.minecraft.client.resources.I18n;
|
2014-04-21 19:13:15 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2015-01-12 19:24:29 -05:00
|
|
|
import net.minecraft.inventory.Slot;
|
2015-03-31 17:16:07 -04:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-12-14 20:05:39 +00:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
2015-01-21 15:15:23 -05:00
|
|
|
import com.cricketcraft.chisel.api.IAdvancedChisel;
|
2015-01-19 11:23:11 -05:00
|
|
|
import com.cricketcraft.chisel.api.IChiselItem;
|
2015-01-21 14:02:47 -05:00
|
|
|
import com.cricketcraft.chisel.api.carving.IChiselMode;
|
2015-08-18 20:40:55 -04:00
|
|
|
|
|
|
|
|
import team.chisel.inventory.ContainerChisel;
|
|
|
|
|
import team.chisel.inventory.InventoryChiselSelection;
|
|
|
|
|
import team.chisel.inventory.SlotChiselInput;
|
|
|
|
|
import team.chisel.item.chisel.ChiselMode;
|
|
|
|
|
import team.chisel.network.PacketHandler;
|
|
|
|
|
import team.chisel.network.message.MessageChiselMode;
|
|
|
|
|
import team.chisel.utils.General;
|
|
|
|
|
import team.chisel.utils.GeneralClient;
|
2014-12-15 00:11:48 +00:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public class GuiChisel extends GuiContainer {
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public EntityPlayer player;
|
|
|
|
|
public ContainerChisel container;
|
2015-01-21 14:02:47 -05:00
|
|
|
private IChiselMode currentMode;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu) {
|
|
|
|
|
super(new ContainerChisel(iinventory, menu));
|
|
|
|
|
player = iinventory.player;
|
2015-01-12 19:24:29 -05:00
|
|
|
xSize = 252;
|
2015-01-12 20:42:32 -05:00
|
|
|
ySize = 202;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
container = (ContainerChisel) inventorySlots;
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@Override
|
|
|
|
|
public void onGuiClosed() {
|
|
|
|
|
super.onGuiClosed();
|
|
|
|
|
inventorySlots.onContainerClosed(player);
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-18 15:58:13 -05:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Override
|
|
|
|
|
public void initGui() {
|
|
|
|
|
super.initGui();
|
|
|
|
|
currentMode = General.getChiselMode(container.chisel);
|
|
|
|
|
|
2015-01-19 11:23:11 -05:00
|
|
|
if (showMode()) {
|
|
|
|
|
int x = this.width / 2 - 120;
|
|
|
|
|
int y = this.height / 2 - 6;
|
|
|
|
|
buttonList.add(new GuiButton(0, x, y, 53, 20, ""));
|
|
|
|
|
setButtonText();
|
|
|
|
|
}
|
2015-01-18 15:58:13 -05:00
|
|
|
}
|
|
|
|
|
|
2015-03-31 17:16:07 -04:00
|
|
|
@Override
|
|
|
|
|
public void updateScreen() {
|
|
|
|
|
super.updateScreen();
|
|
|
|
|
ItemStack held = player.getCurrentEquippedItem();
|
|
|
|
|
if (held == null || !(held.getItem() instanceof IChiselItem)) {
|
|
|
|
|
mc.displayGuiScreen(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-18 15:58:13 -05:00
|
|
|
private void setButtonText() {
|
|
|
|
|
((GuiButton) buttonList.get(0)).displayString = I18n.format(container.inventory.getInventoryName() + ".mode." + currentMode.name().toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-19 11:23:11 -05:00
|
|
|
private boolean showMode() {
|
|
|
|
|
if (container.chisel != null && container.chisel.getItem() instanceof IChiselItem) {
|
|
|
|
|
return ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@Override
|
|
|
|
|
protected void drawGuiContainerForegroundLayer(int j, int i) {
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-12 19:24:29 -05:00
|
|
|
String line = I18n.format(this.container.inventory.getInventoryName() + ".title");
|
|
|
|
|
fontRendererObj.drawSplitString(line, 50 - fontRendererObj.getStringWidth(line) / 2, 60, 40, 0x404040);
|
2015-01-19 11:23:11 -05:00
|
|
|
|
|
|
|
|
if (showMode()) {
|
|
|
|
|
line = I18n.format(this.container.inventory.getInventoryName() + ".mode");
|
|
|
|
|
fontRendererObj.drawString(line, fontRendererObj.getStringWidth(line) / 2 + 6, 85, 0x404040);
|
|
|
|
|
}
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@Override
|
|
|
|
|
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
int i = width - xSize >> 1;
|
|
|
|
|
int j = height - ySize >> 1;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2015-01-12 19:24:29 -05:00
|
|
|
String texture = "chisel:textures/chisel2Gui.png";
|
2015-01-07 19:50:18 -05:00
|
|
|
|
|
|
|
|
GeneralClient.bind(texture);
|
|
|
|
|
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
|
2015-01-13 21:37:04 -05:00
|
|
|
|
|
|
|
|
int x = (width - xSize) / 2;
|
|
|
|
|
int y = (height - ySize) / 2;
|
2015-01-18 15:58:13 -05:00
|
|
|
|
2015-01-13 21:37:04 -05:00
|
|
|
Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots);
|
|
|
|
|
if (main.getStack() == null) {
|
|
|
|
|
GuiAutoChisel.drawSlotOverlay(this, x + 14, y + 14, main, 0, ySize, 60);
|
|
|
|
|
}
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
2015-01-12 19:24:29 -05:00
|
|
|
|
2015-01-18 15:58:13 -05:00
|
|
|
@Override
|
|
|
|
|
protected void actionPerformed(GuiButton button) {
|
|
|
|
|
if (button.id == 0) {
|
2015-01-21 14:02:47 -05:00
|
|
|
if (container.chisel != null && container.chisel.getItem() instanceof IAdvancedChisel) {
|
|
|
|
|
IAdvancedChisel item = (IAdvancedChisel) container.chisel.getItem();
|
|
|
|
|
currentMode = item.getNextMode(container.chisel, currentMode);
|
|
|
|
|
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
|
|
|
|
|
} else {
|
|
|
|
|
currentMode = ChiselMode.next(currentMode);
|
|
|
|
|
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
|
|
|
|
|
setButtonText();
|
|
|
|
|
}
|
2015-01-18 15:58:13 -05:00
|
|
|
}
|
|
|
|
|
super.actionPerformed(button);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 19:24:29 -05:00
|
|
|
@Override
|
|
|
|
|
protected void func_146977_a(Slot slot) {
|
|
|
|
|
if (slot instanceof SlotChiselInput) {
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glScalef(2, 2, 2);
|
|
|
|
|
slot.xDisplayPosition -= 16;
|
|
|
|
|
slot.yDisplayPosition -= 16;
|
|
|
|
|
super.func_146977_a(slot);
|
|
|
|
|
slot.xDisplayPosition += 16;
|
|
|
|
|
slot.yDisplayPosition += 16;
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
} else {
|
|
|
|
|
super.func_146977_a(slot);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|