Finished Sorter GUI
created a simple GUI to allow for turning off slots, and toggling rejection state. Also fixed a bug with the rejection checker where it was always false. Though now i have a bug with the packets never making i to the server.
This commit is contained in:
parent
27e43ebfa7
commit
c97a065429
5 changed files with 132 additions and 30 deletions
|
@ -46,7 +46,7 @@ public class TileEntitySorter extends TileEntityBase implements
|
||||||
/**
|
/**
|
||||||
* on/off value for the GUI buttons
|
* on/off value for the GUI buttons
|
||||||
*/
|
*/
|
||||||
public boolean[] onOff = new boolean[5];
|
public boolean[] onOff = new boolean[]{true,true,true,true,true};
|
||||||
/**
|
/**
|
||||||
* the belt found in the search area
|
* the belt found in the search area
|
||||||
*/
|
*/
|
||||||
|
@ -131,6 +131,7 @@ public class TileEntitySorter extends TileEntityBase implements
|
||||||
this.beltSide.ignoreEntity(entity);
|
this.beltSide.ignoreEntity(entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
System.out.print(" \n fire ");
|
||||||
entity.motionX = (double) side.offsetX * 0.1;
|
entity.motionX = (double) side.offsetX * 0.1;
|
||||||
entity.motionY += 0.10000000298023224D;
|
entity.motionY += 0.10000000298023224D;
|
||||||
entity.motionZ = (double) side.offsetZ * 0.1;
|
entity.motionZ = (double) side.offsetZ * 0.1;
|
||||||
|
@ -202,16 +203,14 @@ public class TileEntitySorter extends TileEntityBase implements
|
||||||
if (i >= this.onOff.length) {
|
if (i >= this.onOff.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean cc = this.onOff[i];
|
if (this.onOff[i]) {
|
||||||
if (cc) {
|
this.onOff[i] = false;
|
||||||
cc = false;
|
|
||||||
} else {
|
} else {
|
||||||
cc = true;
|
this.onOff[i] = true;
|
||||||
}
|
}
|
||||||
this.onOff[i] = cc;
|
|
||||||
if (worldObj.isRemote) {
|
if (worldObj.isRemote) {
|
||||||
Packet packet = PacketManager.getPacket("asmLine", this,
|
Packet packet = PacketManager.getPacket("asmLine", this,
|
||||||
new Object[] { tPacketID.SETTINGON, i });
|
tPacketID.SETTINGON.ordinal(), i );
|
||||||
PacketDispatcher.sendPacketToServer(packet);
|
PacketDispatcher.sendPacketToServer(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,17 +260,18 @@ public class TileEntitySorter extends TileEntityBase implements
|
||||||
try{
|
try{
|
||||||
int id = dataStream.readInt();
|
int id = dataStream.readInt();
|
||||||
tPacketID pID = tPacketID.values()[id];
|
tPacketID pID = tPacketID.values()[id];
|
||||||
|
System.out.print("\n id:"+id+" ");
|
||||||
if(pID == tPacketID.ANIMATION)
|
if(pID == tPacketID.ANIMATION)
|
||||||
{
|
{
|
||||||
this.firePiston = dataStream.readBoolean();
|
this.firePiston = dataStream.readBoolean();
|
||||||
}
|
}else
|
||||||
if(pID == tPacketID.GUI)
|
if(pID == tPacketID.GUI)
|
||||||
{
|
{
|
||||||
for(int i =0; i < this.onOff.length; i++)
|
for(int i =0; i < this.onOff.length; i++)
|
||||||
{
|
{
|
||||||
this.onOff[i] = dataStream.readBoolean();
|
this.onOff[i] = dataStream.readBoolean();
|
||||||
}
|
}
|
||||||
}
|
}else
|
||||||
if(pID == tPacketID.SETTINGON)
|
if(pID == tPacketID.SETTINGON)
|
||||||
{
|
{
|
||||||
int num = dataStream.readInt();
|
int num = dataStream.readInt();
|
||||||
|
|
46
src/minecraft/assemblyline/gui/GuiButtonImage.java
Normal file
46
src/minecraft/assemblyline/gui/GuiButtonImage.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package assemblyline.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.src.GuiButton;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Side;
|
||||||
|
import cpw.mods.fml.common.asm.SideOnly;
|
||||||
|
/**
|
||||||
|
* Copied from GSM lib and modified for this mod only
|
||||||
|
* @author Rseifert
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiButtonImage extends GuiButton
|
||||||
|
{
|
||||||
|
private int type = 0;
|
||||||
|
public GuiButtonImage(int par1, int par2, int par3,int type)
|
||||||
|
{
|
||||||
|
super(par1, par2, par3, 12, 12, "");
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws this button to the screen.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void drawButton(Minecraft par1Minecraft, int width, int hight)
|
||||||
|
{
|
||||||
|
if (this.drawButton)
|
||||||
|
{
|
||||||
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/assemblyline/textures/gui@.png"));
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
|
||||||
|
int var5 = 106;
|
||||||
|
int var6 = 0;
|
||||||
|
if (var4)
|
||||||
|
{
|
||||||
|
var5 += this.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,53 +1,109 @@
|
||||||
package assemblyline.gui;
|
package assemblyline.gui;
|
||||||
|
|
||||||
|
import net.minecraft.src.GuiButton;
|
||||||
import net.minecraft.src.GuiContainer;
|
import net.minecraft.src.GuiContainer;
|
||||||
import net.minecraft.src.InventoryPlayer;
|
import net.minecraft.src.InventoryPlayer;
|
||||||
import net.minecraft.src.StatCollector;
|
import net.minecraft.src.StatCollector;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import assemblyline.AssemblyLine;
|
import assemblyline.AssemblyLine;
|
||||||
import assemblyline.machines.ContainerSorter;
|
import assemblyline.machines.ContainerSorter;
|
||||||
import assemblyline.machines.TileEntitySorter;
|
import assemblyline.machines.TileEntitySorter;
|
||||||
|
|
||||||
public class GuiSorter extends GuiContainer
|
public class GuiSorter extends GuiContainer {
|
||||||
{
|
|
||||||
private TileEntitySorter tileEntity;
|
private TileEntitySorter tileEntity;
|
||||||
|
|
||||||
private int containerWidth;
|
private int containerWidth;
|
||||||
private int containerHeight;
|
private int containerHeight;
|
||||||
|
|
||||||
public GuiSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
public GuiSorter(InventoryPlayer par1InventoryPlayer,
|
||||||
{
|
TileEntitySorter tileEntity) {
|
||||||
super(new ContainerSorter(par1InventoryPlayer, tileEntity));
|
super(new ContainerSorter(par1InventoryPlayer, tileEntity));
|
||||||
this.tileEntity = tileEntity;
|
this.tileEntity = tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void initGui() {
|
||||||
* Draw the foreground layer for the
|
super.initGui();
|
||||||
* GuiContainer (everything in front of the
|
Keyboard.enableRepeatEvents(true);
|
||||||
* items)
|
this.controlList.clear();
|
||||||
*/
|
int wid = (this.width - this.xSize) / 2;
|
||||||
@Override
|
int hig = (this.height - this.ySize) / 2;
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44,19, "Toggle"));
|
||||||
|
for(int i = 1; i < this.tileEntity.onOff.length; i++)
|
||||||
{
|
{
|
||||||
this.fontRenderer.drawString("Ejector Settings", 55, 6, 4210752);
|
this.controlList.add(new GuiButtonImage(i, wid + 17 + i*18, hig + 17, 0));
|
||||||
this.fontRenderer.drawString("Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60, 4210752);
|
}
|
||||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
}
|
||||||
|
|
||||||
|
public void updateScreen() {
|
||||||
|
super.updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the background layer for the
|
* Fired when a control is clicked. This is the equivalent of
|
||||||
* GuiContainer (everything behind the items)
|
* ActionListener.actionPerformed(ActionEvent e).
|
||||||
|
*/
|
||||||
|
protected void actionPerformed(GuiButton button)
|
||||||
|
{
|
||||||
|
if(button.id < 5)
|
||||||
|
{
|
||||||
|
this.tileEntity.changeOnOff(button.id);
|
||||||
|
}
|
||||||
|
super.actionPerformed(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void keyTyped(char par1, int par2) {
|
||||||
|
super.keyTyped(par1, par2);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void mouseClicked(int par1, int par2, int par3) {
|
||||||
|
super.mouseClicked(par1, par2, par3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuiClosed() {
|
||||||
|
super.onGuiClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the foreground layer for the GuiContainer (everything in front of
|
||||||
|
* the items)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||||
{
|
this.fontRenderer.drawString("Ejector Settings", 55, 6, 4210752);
|
||||||
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_ejector.png");
|
this.fontRenderer.drawString(
|
||||||
|
"Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60,
|
||||||
|
4210752);
|
||||||
|
this.fontRenderer.drawString(
|
||||||
|
StatCollector.translateToLocal("container.inventory"), 8,
|
||||||
|
this.ySize - 96 + 2, 4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the background layer for the GuiContainer (everything behind the
|
||||||
|
* items)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float par1, int par2,
|
||||||
|
int par3) {
|
||||||
|
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH
|
||||||
|
+ "gui_ejector.png");
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
this.mc.renderEngine.bindTexture(var4);
|
this.mc.renderEngine.bindTexture(var4);
|
||||||
containerWidth = (this.width - this.xSize) / 2;
|
containerWidth = (this.width - this.xSize) / 2;
|
||||||
containerHeight = (this.height - this.ySize) / 2;
|
containerHeight = (this.height - this.ySize) / 2;
|
||||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0,
|
||||||
|
this.xSize, this.ySize);
|
||||||
|
|
||||||
|
//GUI button changes
|
||||||
|
for(int i = 1; i < this.tileEntity.onOff.length; i++)
|
||||||
|
{
|
||||||
|
this.drawTexturedModalRect(containerWidth+17+i*18, containerHeight+17, 176, +(tileEntity.onOff[i] ? 12 : 0), 12, 12);
|
||||||
|
}
|
||||||
|
this.fontRenderer.drawString(
|
||||||
|
"Reject: "+(tileEntity.onOff[0] ? "Inv" : "Other"), containerWidth + 108,
|
||||||
|
containerHeight +22, 4210752);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
src/minecraft/assemblyline/textures/gui@.png
Normal file
BIN
src/minecraft/assemblyline/textures/gui@.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in a new issue