More imprinter tweakin
This commit is contained in:
parent
805f3ba9ba
commit
6ea1b0ec3a
2 changed files with 82 additions and 75 deletions
|
@ -83,7 +83,7 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
ItemStack slotStack = slotObj.getStack();
|
||||
copyStack = slotStack.copy();
|
||||
|
||||
if (slot == 2)
|
||||
if (slot == this.tileEntity.INVENTORY_START - 1)
|
||||
{
|
||||
// Prevents filter from being duplicated
|
||||
this.tileEntity.setInventorySlotContents(0, null);
|
||||
|
@ -91,11 +91,11 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
|
||||
if (slot > this.tileEntity.getSizeInventory())
|
||||
{
|
||||
if (this.getSlot(0).isItemValid(slotStack))
|
||||
if (this.getSlot(this.tileEntity.IMPRINTER_MATRIX_START).isItemValid(slotStack))
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, 0, 1, false)) { return null; }
|
||||
if (!this.mergeItemStack(slotStack, this.tileEntity.IMPRINTER_MATRIX_START, this.tileEntity.IMPRINTER_MATRIX_START + 1, true)) { return null; }
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.imprinterMatrix.length, this.tileEntity.getSizeInventory(), false)) { return null; }
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.INVENTORY_START, this.tileEntity.getSizeInventory(), false)) { return null; }
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) { return null; }
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
public ItemStack[] containingItems = new ItemStack[18];
|
||||
|
||||
public ContainerImprinter container;
|
||||
private boolean isImprinting = false;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
|
@ -229,36 +230,30 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isMatrixEmpty()
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
if (this.craftingMatrix[i] != null)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all the output slots. Call this to update the Imprinter.
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
/**
|
||||
* Simulate an Inventory Crafting Instance
|
||||
*/
|
||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||
|
||||
/**
|
||||
* Makes the stamping recipe for filters
|
||||
*/
|
||||
boolean didStamp = false;
|
||||
this.isImprinting = false;
|
||||
|
||||
/**
|
||||
* Check crafting matrix. Only allow imprinting if the matrix is clean.
|
||||
*/
|
||||
boolean cleanCraftingMatrix = true;
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
if (inventoryCrafting.getStackInSlot(i) != null)
|
||||
{
|
||||
cleanCraftingMatrix = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (cleanCraftingMatrix && this.imprinterMatrix[0] != null && this.imprinterMatrix[1] != null)
|
||||
if (this.isMatrixEmpty() && this.imprinterMatrix[0] != null && this.imprinterMatrix[1] != null)
|
||||
{
|
||||
if (this.imprinterMatrix[0].getItem() instanceof ItemImprinter)
|
||||
{
|
||||
|
@ -284,11 +279,11 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
|
||||
ItemImprinter.setFilters(outputStack, filters);
|
||||
this.imprinterMatrix[2] = outputStack;
|
||||
didStamp = true;
|
||||
this.isImprinting = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!didStamp)
|
||||
if (!this.isImprinting)
|
||||
{
|
||||
this.imprinterMatrix[2] = null;
|
||||
|
||||
|
@ -297,6 +292,11 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
*/
|
||||
boolean didCraft = false;
|
||||
|
||||
/**
|
||||
* Simulate an Inventory Crafting Instance
|
||||
*/
|
||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||
|
||||
if (inventoryCrafting != null)
|
||||
{
|
||||
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
||||
|
@ -346,6 +346,12 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
public void onPickUpFromResult(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (this.isImprinting)
|
||||
{
|
||||
this.imprinterMatrix[0] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Try to consume resource from the inventory.
|
||||
|
@ -419,6 +425,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this player's inventory contain the required resources to craft this item?
|
||||
|
|
Loading…
Reference in a new issue