Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GUICPU extends GuiContainer {
- public static final ResourceLocation texturegui = new ResourceLocation("programmaticraft:textures/gui/guicpu.png");
- private TileEntityCPU te;
- private GuiButton doneBtn;
- private GuiButton cancelBtn;
- private GuiTextField terminalBox1;
- private GuiTextField terminalBox2;
- private GuiTextField terminalBox3;
- private GuiTextField terminalBox4;
- private GuiTextField terminalBox5;
- private GuiTextField terminalBox6;
- private GuiTextField terminalBox7;
- private GuiTextField terminalBox8;
- private GuiTextField terminalBox9;
- private int xSize;
- private int ySize;
- private BlockPos pos;
- public GUICPU(Container con, BlockPos pos, TileEntityCPU tile) {
- super(con);
- this.xSize = 209;
- this.ySize = 232;
- this.pos = pos;
- this.te = (TileEntityCPU) tile;
- System.out.println(this.pos);
- System.out.println(this.te);
- }
- protected void mouseClicked(int x, int y, int btn) throws IOException {
- super.mouseClicked(x, y, btn);
- this.terminalBox1.mouseClicked(x, y, btn);
- this.terminalBox2.mouseClicked(x, y, btn);
- this.terminalBox3.mouseClicked(x, y, btn);
- this.terminalBox4.mouseClicked(x, y, btn);
- this.terminalBox5.mouseClicked(x, y, btn);
- this.terminalBox6.mouseClicked(x, y, btn);
- this.terminalBox7.mouseClicked(x, y, btn);
- this.terminalBox8.mouseClicked(x, y, btn);
- this.terminalBox9.mouseClicked(x, y, btn);
- }
- public void onGuiClosed()
- {
- Keyboard.enableRepeatEvents(false);
- }
- public void initGui()
- {
- Keyboard.enableRepeatEvents(true);
- this.buttonList.clear();
- System.out.println(this.te.stringList);
- this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 90, this.height / 4 + 170, 81, 20, I18n.format("gui.done", new Object[0])));
- this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 - 9, this.height / 4 + 170, 81, 20, I18n.format("gui.cancel", new Object[0])));
- this.fontRendererObj.drawString("Code Editor" , (this.width / 2) - (this.xSize / 2) + 5, (this.height / 2) - (this.ySize / 2) - 10, 4210752);
- this.terminalBox1 = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, this.height / 2 - this.ySize/2 - 40, 150, 20);
- this.terminalBox1.setMaxStringLength(200);
- this.terminalBox1.setFocused(true);
- this.terminalBox1.setText(( this.te.getLine(0)));
- this.terminalBox2 = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2- 20, 150, 20);
- this.terminalBox2.setMaxStringLength(200);
- this.terminalBox2.setFocused(false);
- this.terminalBox2.setText(( this.te.getLine(1)));
- this.terminalBox3 = new GuiTextField(4, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 - 0, 150, 20);
- this.terminalBox3.setMaxStringLength(200);
- this.terminalBox3.setFocused(false);
- this.terminalBox3.setText(( this.te.getLine(2)));
- this.terminalBox4 = new GuiTextField(5, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 + 20, 150, 20);
- this.terminalBox4.setMaxStringLength(200);
- this.terminalBox4.setFocused(false);
- this.terminalBox4.setText(( this.te.getLine(3)));
- this.terminalBox5 = new GuiTextField(6, this.fontRendererObj, this.width / 2 - 150, this.height / 2 - this.ySize/2+ 40, 150, 20);
- this.terminalBox5.setMaxStringLength(200);
- this.terminalBox5.setFocused(false);
- this.terminalBox5.setText(( this.te.getLine(4)));
- this.terminalBox6 = new GuiTextField(7, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 + 60, 150, 20);
- this.terminalBox6.setMaxStringLength(200);
- this.terminalBox6.setFocused(false);
- this.terminalBox6.setText(( this.te.getLine(5)));
- this.terminalBox7 = new GuiTextField(8, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 + 80, 150, 20);
- this.terminalBox7.setMaxStringLength(200);
- this.terminalBox7.setFocused(false);
- this.terminalBox7.setText(( this.te.getLine(6)));
- this.terminalBox8 = new GuiTextField(9, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 + 100, 150, 20);
- this.terminalBox8.setMaxStringLength(200);
- this.terminalBox8.setFocused(false);
- this.terminalBox8.setText(( this.te.getLine(7)));
- this.terminalBox9 = new GuiTextField(10, this.fontRendererObj, this.width / 2 - 150, this.height / 2- this.ySize/2 + 120, 150, 20);
- this.terminalBox9.setMaxStringLength(200);
- this.terminalBox9.setFocused(false);
- this.terminalBox9.setText(( this.te.getLine(8)));
- }
- protected void actionPerformed(GuiButton button) throws IOException
- {
- if (button.enabled)
- {
- if (button.id == 1)
- {
- this.mc.displayGuiScreen((GuiScreen)null);
- }
- else if (button.id == 0)
- {
- PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
- this.te.setLine(this.terminalBox1.getText(), 0);
- this.te.setLine(this.terminalBox2.getText(), 1);
- this.te.setLine(this.terminalBox3.getText(), 2);
- this.te.setLine(this.terminalBox4.getText(), 3);
- this.te.setLine(this.terminalBox5.getText(), 4);
- this.te.setLine(this.terminalBox6.getText(), 5);
- this.te.setLine(this.terminalBox7.getText(), 6);
- this.te.setLine(this.terminalBox8.getText(), 7);
- this.te.setLine(this.terminalBox9.getText(), 8);
- System.out.println(this.te.stringList);
- for (int i = 0; i < 9; ) {
- switch (i) {
- case 0: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox1.getText(), buffer)); break;}
- case 1: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox2.getText(), buffer)); break;}
- case 2: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox3.getText(), buffer)); break;}
- case 3: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox4.getText(), buffer)); break;}
- case 4: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox5.getText(), buffer)); break;}
- case 5: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox6.getText(), buffer)); break;}
- case 6: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox7.getText(), buffer)); break;}
- case 7: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox8.getText(), buffer)); break;}
- case 8: {
- Main.network.sendToServer(new PacketCPU(this.terminalBox9.getText(), buffer)); break;}
- }
- System.out.println(buffer);
- i++;
- }
- this.mc.displayGuiScreen((GuiScreen)null);
- }
- }
- }
- protected void keyTyped(char par1, int par2) throws IOException
- {
- this.terminalBox1.textboxKeyTyped(par1, par2);
- this.terminalBox2.textboxKeyTyped(par1, par2);
- this.terminalBox3.textboxKeyTyped(par1, par2);
- this.terminalBox4.textboxKeyTyped(par1, par2);
- this.terminalBox5.textboxKeyTyped(par1, par2);
- this.terminalBox6.textboxKeyTyped(par1, par2);
- this.terminalBox7.textboxKeyTyped(par1, par2);
- this.terminalBox8.textboxKeyTyped(par1, par2);
- this.terminalBox9.textboxKeyTyped(par1, par2);
- if(!( par2 == Keyboard.KEY_E))super.keyTyped(par1, par2);
- }
- public void updateScreen()
- {
- super.updateScreen();
- this.terminalBox1.updateCursorCounter();
- this.terminalBox2.updateCursorCounter();
- this.terminalBox3.updateCursorCounter();
- this.terminalBox4.updateCursorCounter();
- this.terminalBox5.updateCursorCounter();
- this.terminalBox6.updateCursorCounter();
- this.terminalBox7.updateCursorCounter();
- this.terminalBox8.updateCursorCounter();
- this.terminalBox9.updateCursorCounter();
- }
- @Override
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
- GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
- this.mc.getTextureManager().bindTexture(texturegui);
- int i = (this.width - this.xSize) / 2;
- int j = (this.height - this.ySize) / 2;
- this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
- }
- @Override
- protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
- this.terminalBox1.drawTextBox();
- this.terminalBox2.drawTextBox();
- this.terminalBox3.drawTextBox();
- this.terminalBox4.drawTextBox();
- this.terminalBox5.drawTextBox();
- this.terminalBox6.drawTextBox();
- this.terminalBox7.drawTextBox();
- this.terminalBox8.drawTextBox();
- this.terminalBox9.drawTextBox();
- }
- @Override
- public boolean doesGuiPauseGame() {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment