Skip to content

Commit

Permalink
Fix StencilTable always creating a wooden tool rod until button is pr…
Browse files Browse the repository at this point in the history
…essed
  • Loading branch information
bonii-xx committed Aug 24, 2014
1 parent d25e7e9 commit 64d6638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/tconstruct/tools/gui/StencilTableGui.java
Expand Up @@ -101,6 +101,9 @@ public void initGui ()
activeButton = StencilBuilder.getIndex(logic.getStackInSlot(1));

setActiveButton(activeButton);
ItemStack stack = StencilBuilder.getStencil(((GuiButtonStencil)this.buttonList.get(activeButton)).element.stencilIndex);
logic.setSelectedPattern(stack);
updateServer(stack);
}

@Override
Expand All @@ -113,7 +116,7 @@ protected void actionPerformed (GuiButton button)
ItemStack stack = StencilBuilder.getStencil(id);
if(stack != null)
{
logic.setInventorySlotContents(1, stack);
logic.setSelectedPattern(stack);
updateServer(stack);
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/tconstruct/tools/logic/StencilTableLogic.java
Expand Up @@ -13,6 +13,8 @@

public class StencilTableLogic extends InventoryLogic implements ISidedInventory
{
private ItemStack selectedStack;

public StencilTableLogic()
{
super(2);
Expand Down Expand Up @@ -44,13 +46,19 @@ public void onInventoryChanged()
super.onInventoryChanged();
}*/

public void setSelectedPattern(ItemStack stack)
{
selectedStack = stack;
this.setInventorySlotContents(1, stack);
}

@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 0 && itemstack != null && StencilBuilder.isBlank(itemstack))
{
setInventorySlotContents(1, new ItemStack(TinkerTools.woodPattern, 1, 1));
setInventorySlotContents(1, selectedStack);
}
}

Expand Down

0 comments on commit 64d6638

Please sign in to comment.