Fix dupe bug on TileAssemblyAdvancedWorkbench

Closes #634
This commit is contained in:
Christian 2013-02-26 14:24:15 -05:00
parent c15f011a02
commit 55660989e4
2 changed files with 30 additions and 13 deletions

View file

@ -132,4 +132,9 @@ public class SimpleInventory implements IInventory, INBTTagable {
this._contents[i] = null; this._contents[i] = null;
return stackToTake; return stackToTake;
} }
public ItemStack[] getItemStacks()
{
return _contents;
}
} }

View file

@ -40,6 +40,7 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
int[] bindings = new int[9]; int[] bindings = new int[9];
ItemStack[] tempStacks; ItemStack[] tempStacks;
public int[] hitCount; public int[] hitCount;
private boolean useRecipeStack;
private InternalInventoryCrafting() { private InternalInventoryCrafting() {
super(new InternalInventoryCraftingContainer(), 3, 3); super(new InternalInventoryCraftingContainer(), 3, 3);
@ -48,14 +49,13 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
@Override @Override
public ItemStack getStackInSlot(int par1) { public ItemStack getStackInSlot(int par1) {
if (par1 >= 0 && par1 < 9) { if (par1 >= 0 && par1 < 9) {
if (tempStacks != null) { if (useRecipeStack || tempStacks == null) {
return craftingSlots.getStackInSlot(par1);
} else {
if (bindings[par1] >= 0) { if (bindings[par1] >= 0) {
return tempStacks[bindings[par1]]; return tempStacks[bindings[par1]];
} }
// unbound returns null
} else {
return craftingSlots.getStackInSlot(par1);
} }
} }
@ -77,6 +77,11 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
else else
return null; return null;
} }
public void recipeUpdate(boolean flag)
{
useRecipeStack = flag;
}
} }
private final class InternalPlayer extends EntityPlayer { private final class InternalPlayer extends EntityPlayer {
@ -271,6 +276,7 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
} }
if (!CoreProxy.proxy.isSimulating(worldObj)) if (!CoreProxy.proxy.isSimulating(worldObj))
return; return;
updateCraftingResults();
tick++; tick++;
tick = tick % recentEnergy.length; tick = tick % recentEnergy.length;
recentEnergy[tick] = 0.0f; recentEnergy[tick] = 0.0f;
@ -357,6 +363,11 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
} }
private void updateCraftingResults() { private void updateCraftingResults() {
if (internalInventoryCrafting == null)
{
return;
}
internalInventoryCrafting.recipeUpdate(true);
if(this.currentRecipe == null || !this.currentRecipe.matches(internalInventoryCrafting, worldObj)) if(this.currentRecipe == null || !this.currentRecipe.matches(internalInventoryCrafting, worldObj))
currentRecipe = CraftingHelper.findMatchingRecipe(internalInventoryCrafting, worldObj); currentRecipe = CraftingHelper.findMatchingRecipe(internalInventoryCrafting, worldObj);
@ -365,6 +376,7 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
resultStack = currentRecipe.getCraftingResult(internalInventoryCrafting); resultStack = currentRecipe.getCraftingResult(internalInventoryCrafting);
} }
craftResult.setInventorySlotContents(0, resultStack); craftResult.setInventorySlotContents(0, resultStack);
internalInventoryCrafting.recipeUpdate(false);
onInventoryChanged(); onInventoryChanged();
} }