Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.altiscraft.benjaminloison.gui;
- import org.lwjgl.opengl.GL11;
- import fr.altiscraft.benjaminloison.api.FileAPI;
- import fr.altiscraft.benjaminloison.common.AltisCraft;
- import fr.altiscraft.benjaminloison.packets.PacketSendMessage;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.entity.EntityClientPlayerMP;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.gui.GuiTextField;
- import net.minecraft.client.resources.I18n;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ResourceLocation;
- public class GuiPhone extends GuiScreen
- {
- int guiWidth = 350, guiHeight = 200;
- private GuiTextField message, player;
- boolean back;
- public GuiPhone(boolean back)
- {
- this.back = back;
- if(back)
- buttonList.add(new CustomBlackButton(1, (width - guiWidth) / 2 + 2, (height - guiHeight) / 2 + 144, I18n.format("back"), 50, 20));
- }
- @Override
- public void drawScreen(int x, int y, float ticks)
- {
- int guiX = (width - guiWidth) / 2, guiY = (height - guiHeight) / 2;
- GL11.glColor4f(1, 1, 1, 1);
- mc.renderEngine.bindTexture(new ResourceLocation(AltisCraft.MODID, "textures/gui/Inventory Background.png"));
- drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth - 3, 15);
- mc.renderEngine.bindTexture(new ResourceLocation(AltisCraft.MODID, "textures/gui/Dark Background.png"));
- drawTexturedModalRect(guiX, guiY + 16, 0, 0, guiWidth - 3, 150);
- fontRendererObj.drawString((I18n.format("item.phone.name")), guiX + 5, guiY + 5, 0xFFFFFF);
- message.drawTextBox();
- player.drawTextBox();
- super.drawScreen(x, y, ticks);
- }
- @Override
- public void initGui()
- {
- int guiX = (width - guiWidth) / 2, guiY = (height - guiHeight) / 2;
- buttonList.clear();
- buttonList.add(new CustomBlackButton(0, guiX + 295, guiY + 144, I18n.format("close"), 50, 20));
- buttonList.add(new CustomOrangeButton(2, guiX + 141, guiY + 105, I18n.format("gui.staff"), 60, 20));
- buttonList.add(new CustomOrangeButton(3, guiX + 15, guiY + 80, I18n.format("send"), 60, 20));
- buttonList.add(new CustomOrangeButton(4, guiX + 78, guiY + 80, I18n.format("gui.police"), 60, 20));
- buttonList.add(new CustomOrangeButton(5, guiX + 141, guiY + 80, I18n.format("gui.doctor"), 60, 20));
- buttonList.add(new CustomOrangeButton(6, guiX + 204, guiY + 80, I18n.format("gui.repairman"), 60, 20));
- buttonList.add(new CustomOrangeButton(7, guiX + 267, guiY + 80, I18n.format("gui.transaltis"), 60, 20));
- message = new GuiTextField(fontRendererObj, guiX + 15, guiY + 60, 310, 15);
- message.setMaxStringLength(FileAPI.configNumberInt("message.maximum.length"));
- message.setText(I18n.format("default.message.field"));
- message.setFocused(true);
- player = new GuiTextField(fontRendererObj, guiX + 15, guiY + 107, 120, 15);
- player.setMaxStringLength(FileAPI.configNumberInt("message.maximum.length"));
- player.setText(I18n.format("default.player.field"));
- super.initGui();
- }
- protected void keyTyped(char c, int i)
- {
- super.keyTyped(c, i);
- message.textboxKeyTyped(c, i);
- player.textboxKeyTyped(c, i);
- }
- protected void mouseClicked(int x, int y, int btn)
- {
- super.mouseClicked(x, y, btn);
- message.mouseClicked(x, y, btn);
- player.mouseClicked(x, y, btn);
- }
- @Override
- protected void actionPerformed(GuiButton btn)
- {
- EntityClientPlayerMP thePlayer = Minecraft.getMinecraft().thePlayer;
- int x = thePlayer.getPlayerCoordinates().posX, y = thePlayer.getPlayerCoordinates().posY, z = thePlayer.getPlayerCoordinates().posZ;
- if(btn.id == 0)
- Minecraft.getMinecraft().displayGuiScreen(null);
- else if(btn.id == 1)
- Minecraft.getMinecraft().displayGuiScreen(new GuiInv());
- else if(btn.id > 1)
- if(message.getText().length() >= FileAPI.configNumber("minimum.message.length"))
- {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().displayGuiScreen(new GuiPhone(back));
- if(btn.id == 2)
- {
- thePlayer.sendChatMessage("/helpop " + message.getText());
- thePlayer.addChatComponentMessage(new ChatComponentText(I18n.format("message.has.been.sent")));
- }
- else if(btn.id == 3)
- thePlayer.sendChatMessage("/msg" + " " + player.getText() + " " + message.getText());
- else if(btn.id == 4)
- AltisCraft.instance.network.sendToServer(new PacketSendMessage(I18n.format("message.grade", I18n.format("police"), x, y, z, thePlayer.getDisplayName(), message.getText()), "police"));
- else if(btn.id == 5)
- AltisCraft.instance.network.sendToServer(new PacketSendMessage(I18n.format("message.grade", I18n.format("doctor"), x, y, z, thePlayer.getDisplayName(), message.getText()), "doctor"));
- else if(btn.id == 6)
- AltisCraft.instance.network.sendToServer(new PacketSendMessage(I18n.format("message.grade", I18n.format("repairman"), x, y, z, thePlayer.getDisplayName(), message.getText()), "repairman"));
- else if(btn.id == 7)
- AltisCraft.instance.network.sendToServer(new PacketSendMessage(I18n.format("message.grade", I18n.format("transaltis"), x, y, z, thePlayer.getDisplayName(), message.getText()), "transaltis"));
- }
- else
- thePlayer.addChatComponentMessage(new ChatComponentText(I18n.format("message.must.be.longer.than.minimum.message.length.characters")));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement