Skip to content

Commit

Permalink
Some tweaks for the crafting station. First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
blue42u committed May 8, 2014
1 parent 6dc00b0 commit 88db4df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/main/java/tconstruct/blocks/logic/CraftingStationLogic.java
Expand Up @@ -22,6 +22,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
public WeakReference<IInventory> furnace;
public boolean tinkerTable;
public boolean stencilTable;
public boolean doubleFirst;

public CraftingStationLogic()
{
Expand All @@ -37,8 +38,10 @@ public Container getGuiContainer (InventoryPlayer inventoryplayer, World world,
patternChest = null;
furnace = null;
tinkerTable = false;
for (int yPos = y - 1; yPos <= y + 1; yPos++)
int[] ys = {y, y - 1, y + 1};
for (byte iy = 0; iy < 3; iy++)
{
int yPos = ys[iy];
for (int xPos = x - 1; xPos <= x + 1; xPos++)
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
Expand All @@ -47,10 +50,10 @@ public Container getGuiContainer (InventoryPlayer inventoryplayer, World world,
if (chest == null && tile instanceof TileEntityChest)
{
chest = new WeakReference(tile);
checkForChest(world, xPos + 1, yPos, zPos);
checkForChest(world, xPos - 1, yPos, zPos);
checkForChest(world, xPos, yPos, zPos + 1);
checkForChest(world, xPos, yPos, zPos - 1);
checkForChest(world, xPos, yPos, zPos, 1, 0);
checkForChest(world, xPos, yPos, zPos, -1, 0);
checkForChest(world, xPos, yPos, zPos, 0, 1);
checkForChest(world, xPos, yPos, zPos, 0, -1);
}
else if (patternChest == null && tile instanceof PatternChestLogic)
patternChest = new WeakReference(tile);
Expand All @@ -65,11 +68,14 @@ else if (tinkerTable == false && tile instanceof ToolStationLogic)
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
}

void checkForChest (World world, int x, int y, int z)
void checkForChest (World world, int x, int y, int z, int dx, int dz)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileEntity tile = world.getTileEntity(x + dx, y, z + dz);
if (tile instanceof TileEntityChest)
{
doubleChest = new WeakReference(tile);
doubleFirst = dx + dz < 0;
}
}

@Override
Expand Down Expand Up @@ -146,4 +152,4 @@ public boolean canUpdate ()
{
return false;
}
}
}
Expand Up @@ -71,13 +71,15 @@ public CraftingStationContainer(InventoryPlayer inventorplayer, CraftingStationL
{
IInventory chest = logic.chest.get();
IInventory doubleChest = logic.doubleChest == null ? null : logic.doubleChest.get();
IInventory firstChest = (logic.doubleFirst ? doubleChest : chest);
IInventory secondChest = (logic.doubleFirst ? chest : doubleChest);
int count = 0;
for (column = 0; column < 9; column++)
{
for (row = 0; row < 6; row++)
{
int value = count < 27 ? count : count - 27;
this.addSlotToContainer(new Slot(count < 27 ? chest : doubleChest, value, -108 + row * 18, 19 + column * 18));
this.addSlotToContainer(new Slot(count < 27 ? firstChest : secondChest, value, -108 + row * 18, 19 + column * 18));
count++;
if (count >= 27 && doubleChest == null)
break;
Expand Down

0 comments on commit 88db4df

Please sign in to comment.