Pretty sure this commit was to fix crates not obeying ISided, but I'm not quite sure...
This commit is contained in:
parent
84c74bc589
commit
8323cee352
5 changed files with 271 additions and 269 deletions
|
@ -1,114 +1,114 @@
|
||||||
package assemblyline.client.gui;
|
package assemblyline.client.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import cpw.mods.fml.client.GuiScrollingList;
|
import cpw.mods.fml.client.GuiScrollingList;
|
||||||
|
|
||||||
public class GuiCommandList extends GuiScrollingList
|
public class GuiCommandList extends GuiScrollingList
|
||||||
{
|
{
|
||||||
private ArrayList<String> commands;
|
private ArrayList<String> commands;
|
||||||
private int selIndex;
|
private int selIndex;
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
|
||||||
public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
|
public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
|
||||||
{
|
{
|
||||||
super(client, width, height, top, bottom, left, entryHeight);
|
super(client, width, height, top, bottom, left, entryHeight);
|
||||||
commands = new ArrayList<String>();
|
commands = new ArrayList<String>();
|
||||||
selIndex = -1;
|
selIndex = -1;
|
||||||
this.mc = client;
|
this.mc = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommands(ArrayList<String> commands)
|
public void setCommands(ArrayList<String> commands)
|
||||||
{
|
{
|
||||||
this.commands = (ArrayList<String>) commands.clone();
|
this.commands = (ArrayList<String>) commands.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getSize()
|
protected int getSize()
|
||||||
{
|
{
|
||||||
return commands.size();
|
return commands.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void elementClicked(int index, boolean doubleClick)
|
protected void elementClicked(int index, boolean doubleClick)
|
||||||
{
|
{
|
||||||
selIndex = index;
|
selIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSelected(int index)
|
protected boolean isSelected(int index)
|
||||||
{
|
{
|
||||||
return selIndex == index;
|
return selIndex == index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground()
|
protected void drawBackground()
|
||||||
{
|
{
|
||||||
drawOutlineRect(this.left, this.left + this.listWidth, this.top, this.top + this.listHeight, 0, 0, 0, 0.5f, 0.5f, 0.5f);
|
drawOutlineRect(this.left, this.left + this.listWidth, this.top, this.top + this.listHeight, 0, 0, 0, 0.5f, 0.5f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB)
|
public static void drawOutlineRect(int x1, int y1, int x2, int y2, float rR, float rG, float rB, float lR, float lG, float lB)
|
||||||
{
|
{
|
||||||
Tessellator tesselator = Tessellator.instance;
|
Tessellator tesselator = Tessellator.instance;
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
GL11.glColor4f(rR, rG, rB, 1f);
|
GL11.glColor4f(rR, rG, rB, 1f);
|
||||||
if (rR > 0 && rG > 0 && rB > 0)
|
if (rR > 0 && rG > 0 && rB > 0)
|
||||||
{
|
{
|
||||||
// background
|
// background
|
||||||
tesselator.startDrawingQuads();
|
tesselator.startDrawingQuads();
|
||||||
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
||||||
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
||||||
tesselator.draw();
|
tesselator.draw();
|
||||||
}
|
}
|
||||||
// outline
|
// outline
|
||||||
GL11.glColor4f(lR, lG, lB, 1f);
|
GL11.glColor4f(lR, lG, lB, 1f);
|
||||||
tesselator.startDrawingQuads();
|
tesselator.startDrawingQuads();
|
||||||
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
||||||
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x1 + 1, (double) y2, 0.0D);
|
tesselator.addVertex((double) x1 + 1, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x1 + 1, (double) y1, 0.0D);
|
tesselator.addVertex((double) x1 + 1, (double) y1, 0.0D);
|
||||||
tesselator.draw();
|
tesselator.draw();
|
||||||
tesselator.startDrawingQuads();
|
tesselator.startDrawingQuads();
|
||||||
tesselator.addVertex((double) x2 - 1, (double) y1, 0.0D);
|
tesselator.addVertex((double) x2 - 1, (double) y1, 0.0D);
|
||||||
tesselator.addVertex((double) x2 - 1, (double) y2, 0.0D);
|
tesselator.addVertex((double) x2 - 1, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
||||||
tesselator.draw();
|
tesselator.draw();
|
||||||
tesselator.startDrawingQuads();
|
tesselator.startDrawingQuads();
|
||||||
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
tesselator.addVertex((double) x1, (double) y1, 0.0D);
|
||||||
tesselator.addVertex((double) x1, (double) y1 + 1, 0.0D);
|
tesselator.addVertex((double) x1, (double) y1 + 1, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y1 + 1, 0.0D);
|
tesselator.addVertex((double) x2, (double) y1 + 1, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
tesselator.addVertex((double) x2, (double) y1, 0.0D);
|
||||||
tesselator.draw();
|
tesselator.draw();
|
||||||
tesselator.startDrawingQuads();
|
tesselator.startDrawingQuads();
|
||||||
tesselator.addVertex((double) x1, (double) y2 - 1, 0.0D);
|
tesselator.addVertex((double) x1, (double) y2 - 1, 0.0D);
|
||||||
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
tesselator.addVertex((double) x1, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
tesselator.addVertex((double) x2, (double) y2, 0.0D);
|
||||||
tesselator.addVertex((double) x2, (double) y2 - 1, 0.0D);
|
tesselator.addVertex((double) x2, (double) y2 - 1, 0.0D);
|
||||||
tesselator.draw();
|
tesselator.draw();
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator)
|
protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator)
|
||||||
{
|
{
|
||||||
if (slotID < commands.size())
|
if (slotID < commands.size())
|
||||||
{
|
{
|
||||||
String command = commands.get(slotID);
|
String command = commands.get(slotID);
|
||||||
if (isSelected(slotID))
|
if (isSelected(slotID))
|
||||||
drawOutlineRect(this.left, this.left + width, this.top + slotY, this.top + slotY + slotHeight, -1, -1, -1, 0.5f, 0.5f, 0.5f);
|
drawOutlineRect(this.left, this.left + width, this.top + slotY, this.top + slotY + slotHeight, -1, -1, -1, 0.5f, 0.5f, 0.5f);
|
||||||
this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false);
|
this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class CommonProxy implements IGuiHandler
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
//System.out.println("Server GUI request for ID " + ID);
|
||||||
|
|
||||||
switch (ID)
|
switch (ID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TileEntityCrate extends TileEntityImprintable implements ISidedInve
|
||||||
{
|
{
|
||||||
return this.containingItems[par1];
|
return this.containingItems[par1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int par1, int par2)
|
public ItemStack decrStackSize(int par1, int par2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package assemblyline.common.machine.encoder;
|
package assemblyline.common.machine.encoder;
|
||||||
|
|
||||||
public interface IInventoryWatcher
|
public interface IInventoryWatcher
|
||||||
{
|
{
|
||||||
public void inventoryChanged();
|
public void inventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,148 +1,148 @@
|
||||||
package assemblyline.common.machine.encoder;
|
package assemblyline.common.machine.encoder;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.common.ISidedInventory;
|
import net.minecraftforge.common.ISidedInventory;
|
||||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||||
|
|
||||||
public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory
|
public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory
|
||||||
{
|
{
|
||||||
|
|
||||||
private ItemStack disk;
|
private ItemStack disk;
|
||||||
private IInventoryWatcher watcher;
|
private IInventoryWatcher watcher;
|
||||||
|
|
||||||
public TileEntityEncoder()
|
public TileEntityEncoder()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot)
|
public ItemStack getStackInSlot(int slot)
|
||||||
{
|
{
|
||||||
if (slot == 0)
|
if (slot == 0)
|
||||||
return disk;
|
return disk;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int slot, int amount)
|
public ItemStack decrStackSize(int slot, int amount)
|
||||||
{
|
{
|
||||||
if (slot == 0)
|
if (slot == 0)
|
||||||
{
|
{
|
||||||
if (amount >= 1)
|
if (amount >= 1)
|
||||||
{
|
{
|
||||||
ItemStack ret = disk.copy();
|
ItemStack ret = disk.copy();
|
||||||
disk = null;
|
disk = null;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watcher.inventoryChanged();
|
watcher.inventoryChanged();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int slot)
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||||
{
|
{
|
||||||
if (slot == 0)
|
if (slot == 0)
|
||||||
{
|
{
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
if (stack.stackSize > 1)
|
if (stack.stackSize > 1)
|
||||||
{
|
{
|
||||||
stack.stackSize = 1;
|
stack.stackSize = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disk = stack;
|
disk = stack;
|
||||||
}
|
}
|
||||||
if (watcher != null)
|
if (watcher != null)
|
||||||
watcher.inventoryChanged();
|
watcher.inventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInvName()
|
public String getInvName()
|
||||||
{
|
{
|
||||||
return "Encoder";
|
return "Encoder";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInventoryStackLimit()
|
public int getInventoryStackLimit()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUseableByPlayer(EntityPlayer player)
|
public boolean isUseableByPlayer(EntityPlayer player)
|
||||||
{
|
{
|
||||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
|
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openChest()
|
public void openChest()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeChest()
|
public void closeChest()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWatcher(IInventoryWatcher watcher)
|
public void setWatcher(IInventoryWatcher watcher)
|
||||||
{
|
{
|
||||||
this.watcher = watcher;
|
this.watcher = watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInventoryWatcher getWatcher()
|
public IInventoryWatcher getWatcher()
|
||||||
{
|
{
|
||||||
return this.watcher;
|
return this.watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStartInventorySide(ForgeDirection side)
|
public int getStartInventorySide(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventorySide(ForgeDirection side)
|
public int getSizeInventorySide(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return (side == ForgeDirection.UP) ? 1 : 0;
|
return (side == ForgeDirection.UP) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
NBTTagCompound diskNBT = new NBTTagCompound();
|
NBTTagCompound diskNBT = new NBTTagCompound();
|
||||||
disk.writeToNBT(diskNBT);
|
disk.writeToNBT(diskNBT);
|
||||||
nbt.setCompoundTag("disk", diskNBT);
|
nbt.setCompoundTag("disk", diskNBT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
|
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
|
||||||
if (diskNBT != null)
|
if (diskNBT != null)
|
||||||
{
|
{
|
||||||
disk = ItemStack.loadItemStackFromNBT(diskNBT);
|
disk = ItemStack.loadItemStackFromNBT(diskNBT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue