You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB
Java

package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.TileEntity;
public class GuiWiring extends GuiScreen {
private ToolWiring tool;
private int x;
private int y;
private int z;
private ChipTileEntity chip;
@Override
public void initGui() {
//this.height - 240 is top
//This.width / 2 - 214 is left
//Inputs
if(chip.inputs != null && this.tool.type.equals("output")) {
for (int i = 0; i < chip.inputs.length; i++) {
this.controlList.add(new GuiButtonExtended(this.width / 2 - chip.inputs[i].x, this.height - chip.inputs[i].y, chip.inputs[i].buttonString, "Input", chip.inputs[i].slot));
}
}
//Outputs
if(chip.outputs != null && !this.tool.type.equals("output")) {
for (int i = 0; i < chip.outputs.length; i++) {
this.controlList.add(new GuiButtonExtended(this.width / 2 - chip.outputs[i].x, this.height - chip.outputs[i].y, chip.outputs[i].buttonString, "Output", chip.outputs[i].slot));
}
}
}
public GuiWiring(EntityPlayer player, ToolWiring tool, ChipTileEntity chip, int x, int y, int z) {
super.initGui();
this.tool = tool;
this.x = x;
this.y = y;
this.z = z;
this.chip = chip;
}
@Override
protected void actionPerformed(GuiButton guiButton){
this.actionPerformed((GuiButtonExtended)guiButton);
}
protected void actionPerformed(GuiButtonExtended guibutton) {
if(this.tool.type.equals("unpaired")) {
if (guibutton.type.equals("Input")) {
this.tool.type = "input";
this.tool.slot = guibutton.slot;
this.tool.x = x;
this.tool.y = y;
this.tool.z = z;
} else if (guibutton.type.equals("Output")) {
this.tool.type = "output";
this.tool.slot = guibutton.slot;
this.tool.x = x;
this.tool.y = y;
this.tool.z = z;
}
} else if(this.tool.type.equals("output")) {
this.chip.inputs[guibutton.slot].wire = new WireConnection(tool.x, tool.y, tool.z, guibutton.slot, tool.slot);
System.out.print(guibutton.slot + " " + tool.slot);
tool.type = "unpaired";
}
this.mc.displayGuiScreen(null);
}
}