parent
c15f011a02
commit
55660989e4
2 changed files with 30 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) Krapht, 2011
|
* Copyright (c) Krapht, 2011
|
||||||
*
|
*
|
||||||
* "LogisticsPipes" is distributed under the terms of the Minecraft Mod Public
|
* "LogisticsPipes" is distributed under the terms of the Minecraft Mod Public
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||||
*/
|
*/
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,17 +49,16 @@ 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vanilla returns null for out of bound stacks in InventoryCrafting as well
|
// vanilla returns null for out of bound stacks in InventoryCrafting as well
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -279,10 +285,10 @@ public class TileAssemblyAdvancedWorkbench extends TileEntity implements IInvent
|
||||||
internalInventoryCrafting.tempStacks = tempStorage;
|
internalInventoryCrafting.tempStacks = tempStorage;
|
||||||
internalInventoryCrafting.hitCount = new int[27];
|
internalInventoryCrafting.hitCount = new int[27];
|
||||||
for (int j = 0; j < craftingSlots.getSizeInventory(); j++) {
|
for (int j = 0; j < craftingSlots.getSizeInventory(); j++) {
|
||||||
if (craftingSlots.getStackInSlot(j) == null) {
|
if (craftingSlots.getStackInSlot(j) == null) {
|
||||||
internalInventoryCrafting.bindings[j] = -1;
|
internalInventoryCrafting.bindings[j] = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean matchedStorage = false;
|
boolean matchedStorage = false;
|
||||||
for (int i = 0; i < tempStorage.length; i++) {
|
for (int i = 0; i < tempStorage.length; i++) {
|
||||||
if (tempStorage[i] != null && craftingSlots.getStackInSlot(j).isItemEqual(tempStorage[i])
|
if (tempStorage[i] != null && craftingSlots.getStackInSlot(j).isItemEqual(tempStorage[i])
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue