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.

71 lines
2.6 KiB
Java

package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import org.lwjgl.input.Mouse;
public class GuiWiring extends GuiScrollable {
private ToolWiring tool;
private int x;
private int y;
private int z;
private AbstractWireTileEntity wireEntity;
@Override
public void initGui() {
//this.height - 240 is top
//This.width / 2 - 214 is left
//Inputs
if(wireEntity.inputs != null && this.tool.type.equals("output")) {
for (int i = 0; i < wireEntity.inputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i + 1, this.width, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot));
}
}
//Outputs
if(wireEntity.outputs != null && !this.tool.type.equals("output")) {
for (int i = 0; i < wireEntity.outputs.length; i++) {
this.controlList.add(new GuiButtonExtended(i + 1, this.width, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot));
}
}
}
public GuiWiring(EntityPlayer player, ToolWiring tool, AbstractWireTileEntity wireEntity, int x, int y, int z) {
super.initGui();
this.tool = tool;
this.x = x;
this.y = y;
this.z = z;
this.wireEntity = wireEntity;
}
@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.wireEntity.inputs[guibutton.slot].wire = new WireConnection(tool.x, tool.y, tool.z, guibutton.slot, tool.slot);
tool.type = "unpaired";
}
this.mc.displayGuiScreen(null);
}
}