From 8323cee3524e20eacd76d621c5ac26f88fa7d71c Mon Sep 17 00:00:00 2001 From: Brian Ricketts Date: Thu, 3 Jan 2013 22:06:36 -0600 Subject: [PATCH] Pretty sure this commit was to fix crates not obeying ISided, but I'm not quite sure... --- .../client/gui/GuiCommandList.java | 228 +++++++------- .../assemblyline/common/CommonProxy.java | 2 + .../common/block/TileEntityCrate.java | 2 +- .../machine/encoder/IInventoryWatcher.java | 12 +- .../machine/encoder/TileEntityEncoder.java | 296 +++++++++--------- 5 files changed, 271 insertions(+), 269 deletions(-) diff --git a/src/minecraft/assemblyline/client/gui/GuiCommandList.java b/src/minecraft/assemblyline/client/gui/GuiCommandList.java index aeee766d..d80480c4 100644 --- a/src/minecraft/assemblyline/client/gui/GuiCommandList.java +++ b/src/minecraft/assemblyline/client/gui/GuiCommandList.java @@ -1,114 +1,114 @@ -package assemblyline.client.gui; - -import java.util.ArrayList; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; -import cpw.mods.fml.client.GuiScrollingList; - -public class GuiCommandList extends GuiScrollingList -{ - private ArrayList commands; - private int selIndex; - private Minecraft mc; - - public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) - { - super(client, width, height, top, bottom, left, entryHeight); - commands = new ArrayList(); - selIndex = -1; - this.mc = client; - } - - public void setCommands(ArrayList commands) - { - this.commands = (ArrayList) commands.clone(); - } - - @Override - protected int getSize() - { - return commands.size(); - } - - @Override - protected void elementClicked(int index, boolean doubleClick) - { - selIndex = index; - } - - @Override - protected boolean isSelected(int index) - { - return selIndex == index; - } - - @Override - 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); - } - - 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; - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(rR, rG, rB, 1f); - if (rR > 0 && rG > 0 && rB > 0) - { - // background - tesselator.startDrawingQuads(); - tesselator.addVertex((double) x1, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y1, 0.0D); - tesselator.addVertex((double) x1, (double) y1, 0.0D); - tesselator.draw(); - } - // outline - GL11.glColor4f(lR, lG, lB, 1f); - tesselator.startDrawingQuads(); - tesselator.addVertex((double) x1, (double) y1, 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) y1, 0.0D); - tesselator.draw(); - tesselator.startDrawingQuads(); - tesselator.addVertex((double) x2 - 1, (double) y1, 0.0D); - tesselator.addVertex((double) x2 - 1, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y1, 0.0D); - tesselator.draw(); - tesselator.startDrawingQuads(); - tesselator.addVertex((double) x1, (double) y1, 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, 0.0D); - tesselator.draw(); - tesselator.startDrawingQuads(); - tesselator.addVertex((double) x1, (double) y2 - 1, 0.0D); - tesselator.addVertex((double) x1, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y2, 0.0D); - tesselator.addVertex((double) x2, (double) y2 - 1, 0.0D); - tesselator.draw(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - } - - @Override - protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator) - { - if (slotID < commands.size()) - { - String command = commands.get(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); - this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false); - } - } - -} +package assemblyline.client.gui; + +import java.util.ArrayList; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import cpw.mods.fml.client.GuiScrollingList; + +public class GuiCommandList extends GuiScrollingList +{ + private ArrayList commands; + private int selIndex; + private Minecraft mc; + + public GuiCommandList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) + { + super(client, width, height, top, bottom, left, entryHeight); + commands = new ArrayList(); + selIndex = -1; + this.mc = client; + } + + public void setCommands(ArrayList commands) + { + this.commands = (ArrayList) commands.clone(); + } + + @Override + protected int getSize() + { + return commands.size(); + } + + @Override + protected void elementClicked(int index, boolean doubleClick) + { + selIndex = index; + } + + @Override + protected boolean isSelected(int index) + { + return selIndex == index; + } + + @Override + 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); + } + + 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; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(rR, rG, rB, 1f); + if (rR > 0 && rG > 0 && rB > 0) + { + // background + tesselator.startDrawingQuads(); + tesselator.addVertex((double) x1, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y1, 0.0D); + tesselator.addVertex((double) x1, (double) y1, 0.0D); + tesselator.draw(); + } + // outline + GL11.glColor4f(lR, lG, lB, 1f); + tesselator.startDrawingQuads(); + tesselator.addVertex((double) x1, (double) y1, 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) y1, 0.0D); + tesselator.draw(); + tesselator.startDrawingQuads(); + tesselator.addVertex((double) x2 - 1, (double) y1, 0.0D); + tesselator.addVertex((double) x2 - 1, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y1, 0.0D); + tesselator.draw(); + tesselator.startDrawingQuads(); + tesselator.addVertex((double) x1, (double) y1, 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, 0.0D); + tesselator.draw(); + tesselator.startDrawingQuads(); + tesselator.addVertex((double) x1, (double) y2 - 1, 0.0D); + tesselator.addVertex((double) x1, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y2, 0.0D); + tesselator.addVertex((double) x2, (double) y2 - 1, 0.0D); + tesselator.draw(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } + + @Override + protected void drawSlot(int slotID, int width, int slotY, int slotHeight, Tessellator tessellator) + { + if (slotID < commands.size()) + { + String command = commands.get(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); + this.mc.fontRenderer.drawString(command, this.left + 4, slotY + 4, 0xAAAAAA, false); + } + } + +} diff --git a/src/minecraft/assemblyline/common/CommonProxy.java b/src/minecraft/assemblyline/common/CommonProxy.java index e88d4c3c..d6cc17fe 100644 --- a/src/minecraft/assemblyline/common/CommonProxy.java +++ b/src/minecraft/assemblyline/common/CommonProxy.java @@ -40,6 +40,8 @@ public class CommonProxy implements IGuiHandler public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + //System.out.println("Server GUI request for ID " + ID); switch (ID) { diff --git a/src/minecraft/assemblyline/common/block/TileEntityCrate.java b/src/minecraft/assemblyline/common/block/TileEntityCrate.java index 8cf3b03e..8b3616b4 100644 --- a/src/minecraft/assemblyline/common/block/TileEntityCrate.java +++ b/src/minecraft/assemblyline/common/block/TileEntityCrate.java @@ -71,7 +71,7 @@ public class TileEntityCrate extends TileEntityImprintable implements ISidedInve { return this.containingItems[par1]; } - + @Override public ItemStack decrStackSize(int par1, int par2) { diff --git a/src/minecraft/assemblyline/common/machine/encoder/IInventoryWatcher.java b/src/minecraft/assemblyline/common/machine/encoder/IInventoryWatcher.java index 87cba21c..8bfc9719 100644 --- a/src/minecraft/assemblyline/common/machine/encoder/IInventoryWatcher.java +++ b/src/minecraft/assemblyline/common/machine/encoder/IInventoryWatcher.java @@ -1,6 +1,6 @@ -package assemblyline.common.machine.encoder; - -public interface IInventoryWatcher -{ - public void inventoryChanged(); -} +package assemblyline.common.machine.encoder; + +public interface IInventoryWatcher +{ + public void inventoryChanged(); +} diff --git a/src/minecraft/assemblyline/common/machine/encoder/TileEntityEncoder.java b/src/minecraft/assemblyline/common/machine/encoder/TileEntityEncoder.java index 206c528f..86eabf5c 100644 --- a/src/minecraft/assemblyline/common/machine/encoder/TileEntityEncoder.java +++ b/src/minecraft/assemblyline/common/machine/encoder/TileEntityEncoder.java @@ -1,148 +1,148 @@ -package assemblyline.common.machine.encoder; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.ISidedInventory; -import universalelectricity.prefab.tile.TileEntityAdvanced; - -public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory -{ - - private ItemStack disk; - private IInventoryWatcher watcher; - - public TileEntityEncoder() - { - super(); - } - - @Override - public int getSizeInventory() - { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - if (slot == 0) - return disk; - return null; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) - { - if (slot == 0) - { - if (amount >= 1) - { - ItemStack ret = disk.copy(); - disk = null; - return ret; - } - } - watcher.inventoryChanged(); - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - return null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) - { - if (slot == 0) - { - if (stack != null) - { - if (stack.stackSize > 1) - { - stack.stackSize = 1; - } - } - disk = stack; - } - if (watcher != null) - watcher.inventoryChanged(); - } - - @Override - public String getInvName() - { - return "Encoder"; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - @Override - 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; - } - - @Override - public void openChest() - { - } - - @Override - public void closeChest() - { - } - - public void setWatcher(IInventoryWatcher watcher) - { - this.watcher = watcher; - } - - public IInventoryWatcher getWatcher() - { - return this.watcher; - } - - @Override - public int getStartInventorySide(ForgeDirection side) - { - return 0; - } - - @Override - public int getSizeInventorySide(ForgeDirection side) - { - return (side == ForgeDirection.UP) ? 1 : 0; - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - - NBTTagCompound diskNBT = new NBTTagCompound(); - disk.writeToNBT(diskNBT); - nbt.setCompoundTag("disk", diskNBT); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - - NBTTagCompound diskNBT = nbt.getCompoundTag("disk"); - if (diskNBT != null) - { - disk = ItemStack.loadItemStackFromNBT(diskNBT); - } - } - -} +package assemblyline.common.machine.encoder; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +import universalelectricity.prefab.tile.TileEntityAdvanced; + +public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory +{ + + private ItemStack disk; + private IInventoryWatcher watcher; + + public TileEntityEncoder() + { + super(); + } + + @Override + public int getSizeInventory() + { + return 1; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + if (slot == 0) + return disk; + return null; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) + { + if (slot == 0) + { + if (amount >= 1) + { + ItemStack ret = disk.copy(); + disk = null; + return ret; + } + } + watcher.inventoryChanged(); + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + if (slot == 0) + { + if (stack != null) + { + if (stack.stackSize > 1) + { + stack.stackSize = 1; + } + } + disk = stack; + } + if (watcher != null) + watcher.inventoryChanged(); + } + + @Override + public String getInvName() + { + return "Encoder"; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + @Override + 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; + } + + @Override + public void openChest() + { + } + + @Override + public void closeChest() + { + } + + public void setWatcher(IInventoryWatcher watcher) + { + this.watcher = watcher; + } + + public IInventoryWatcher getWatcher() + { + return this.watcher; + } + + @Override + public int getStartInventorySide(ForgeDirection side) + { + return 0; + } + + @Override + public int getSizeInventorySide(ForgeDirection side) + { + return (side == ForgeDirection.UP) ? 1 : 0; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + + NBTTagCompound diskNBT = new NBTTagCompound(); + disk.writeToNBT(diskNBT); + nbt.setCompoundTag("disk", diskNBT); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + + NBTTagCompound diskNBT = nbt.getCompoundTag("disk"); + if (diskNBT != null) + { + disk = ItemStack.loadItemStackFromNBT(diskNBT); + } + } + +}