Got imprinter to not crash
This commit is contained in:
parent
39aa469436
commit
f9eb91bbbe
3 changed files with 59 additions and 55 deletions
|
@ -9,6 +9,7 @@ import assemblyline.common.AssemblyLine;
|
||||||
|
|
||||||
public class ContainerImprinter extends Container implements ISlotWatcher
|
public class ContainerImprinter extends Container implements ISlotWatcher
|
||||||
{
|
{
|
||||||
|
|
||||||
private InventoryPlayer inventoryPlayer;
|
private InventoryPlayer inventoryPlayer;
|
||||||
public TileEntityImprinter tileEntity;
|
public TileEntityImprinter tileEntity;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
||||||
{
|
{
|
||||||
for (int y = 0; y < 3; y++)
|
for (int y = 0; y < 3; y++)
|
||||||
{
|
{
|
||||||
this.addSlotToContainer(new Slot(this.tileEntity, y + x, 9 + y * 18, 16 + x * 18));
|
this.addSlotToContainer(new Slot(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,11 +37,11 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
||||||
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||||
|
|
||||||
// Imprinter Inventory
|
// Imprinter Inventory
|
||||||
for (int i = 0; i < 9; i++)
|
for (int ii = 0; ii < 2; ii++)
|
||||||
{
|
{
|
||||||
for (int ii = 0; ii < 2; ii++)
|
for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, i + this.tileEntity.imprinterMatrix.length - 1, 8 + i * 18, 80 + ii * 18, this));
|
this.addSlotToContainer(new WatchedSlot(this.tileEntity, (i + ii * 9) + this.tileEntity.INVENTORY_START, 8 + i * 18, 80 + ii * 18, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package assemblyline.common.machine.imprinter;
|
|
||||||
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
|
|
||||||
public class InventoryImprinterCrafting extends InventoryCrafting
|
|
||||||
{
|
|
||||||
|
|
||||||
public InventoryImprinterCrafting(Container par1Container, int par2, int par3)
|
|
||||||
{
|
|
||||||
super(par1Container, par2, par3);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -34,7 +34,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
/**
|
/**
|
||||||
* 9 slots for crafting, 1 slot for an imprint, 1 slot for an item
|
* 9 slots for crafting, 1 slot for an imprint, 1 slot for an item
|
||||||
*/
|
*/
|
||||||
public InventoryImprinterCrafting craftingMatrix = new InventoryImprinterCrafting(null, 3, 3);
|
public ItemStack[] craftingMatrix = new ItemStack[9];
|
||||||
|
|
||||||
public ItemStack[] imprinterMatrix = new ItemStack[3];
|
public ItemStack[] imprinterMatrix = new ItemStack[3];
|
||||||
|
|
||||||
|
@ -67,18 +67,47 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
{
|
{
|
||||||
return this.imprinterMatrix.length + this.containingItems.length;
|
return this.craftingMatrix.length + this.imprinterMatrix.length + this.containingItems.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (slot < this.getSizeInventory())
|
||||||
|
{
|
||||||
|
if (slot < IMPRINTER_MATRIX_START)
|
||||||
|
{
|
||||||
|
this.craftingMatrix[slot] = itemStack;
|
||||||
|
}
|
||||||
|
else if (slot < INVENTORY_START)
|
||||||
|
{
|
||||||
|
this.imprinterMatrix[slot - IMPRINTER_MATRIX_START] = itemStack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.containingItems[slot - INVENTORY_START] = itemStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot)
|
public ItemStack getStackInSlot(int slot)
|
||||||
{
|
{
|
||||||
if (slot < 9)
|
if (slot < IMPRINTER_MATRIX_START)
|
||||||
{
|
{
|
||||||
return this.craftingMatrix.getStackInSlot(slot);
|
return this.craftingMatrix[slot];
|
||||||
|
}
|
||||||
|
else if (slot < INVENTORY_START)
|
||||||
|
{
|
||||||
|
return this.imprinterMatrix[slot - IMPRINTER_MATRIX_START];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.containingItems[slot - INVENTORY_START];
|
||||||
}
|
}
|
||||||
else if (slot < 11) { return this.imprinterMatrix[slot - IMPRINTER_MATRIX_START]; }
|
|
||||||
return this.containingItems[slot - IMPRINTER_MATRIX_START];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,23 +116,23 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int i, int amount)
|
public ItemStack decrStackSize(int i, int amount)
|
||||||
{
|
{
|
||||||
if (this.containingItems[i] != null)
|
if (this.getStackInSlot(i) != null)
|
||||||
{
|
{
|
||||||
ItemStack var3;
|
ItemStack var3;
|
||||||
|
|
||||||
if (this.containingItems[i].stackSize <= amount)
|
if (this.getStackInSlot(i).stackSize <= amount)
|
||||||
{
|
{
|
||||||
var3 = this.containingItems[i];
|
var3 = this.getStackInSlot(i);
|
||||||
this.containingItems[i] = null;
|
this.setInventorySlotContents(i, null);
|
||||||
return var3;
|
return var3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var3 = this.containingItems[i].splitStack(amount);
|
var3 = this.getStackInSlot(i).splitStack(amount);
|
||||||
|
|
||||||
if (this.containingItems[i].stackSize == 0)
|
if (this.getStackInSlot(i).stackSize == 0)
|
||||||
{
|
{
|
||||||
this.containingItems[i] = null;
|
this.setInventorySlotContents(i, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return var3;
|
return var3;
|
||||||
|
@ -121,10 +150,10 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int slot)
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
{
|
{
|
||||||
if (this.containingItems[slot] != null && slot != 2)
|
if (this.getStackInSlot(slot) != null && slot != 2)
|
||||||
{
|
{
|
||||||
ItemStack var2 = this.containingItems[slot];
|
ItemStack var2 = this.getStackInSlot(slot);
|
||||||
this.containingItems[slot] = null;
|
this.setInventorySlotContents(slot, null);
|
||||||
return var2;
|
return var2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -133,18 +162,6 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
|
||||||
{
|
|
||||||
if (par1 < this.containingItems.length)
|
|
||||||
{
|
|
||||||
this.containingItems[par1] = par2ItemStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInvName()
|
public String getInvName()
|
||||||
{
|
{
|
||||||
|
@ -405,14 +422,14 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
|
|
||||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||||
|
|
||||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
for (int i = 0; i < var2.tagCount(); ++i)
|
||||||
{
|
{
|
||||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(i);
|
||||||
byte var5 = var4.getByte("Slot");
|
byte var5 = var4.getByte("Slot");
|
||||||
|
|
||||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
if (var5 >= 0 && var5 < this.getSizeInventory())
|
||||||
{
|
{
|
||||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
this.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(var4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,13 +444,13 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
|
|
||||||
NBTTagList var2 = new NBTTagList();
|
NBTTagList var2 = new NBTTagList();
|
||||||
|
|
||||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
for (int i = 0; i < this.getSizeInventory(); ++i)
|
||||||
{
|
{
|
||||||
if (this.containingItems[var3] != null)
|
if (this.getStackInSlot(i) != null)
|
||||||
{
|
{
|
||||||
NBTTagCompound var4 = new NBTTagCompound();
|
NBTTagCompound var4 = new NBTTagCompound();
|
||||||
var4.setByte("Slot", (byte) var3);
|
var4.setByte("Slot", (byte) i);
|
||||||
this.containingItems[var3].writeToNBT(var4);
|
this.getStackInSlot(i).writeToNBT(var4);
|
||||||
var2.appendTag(var4);
|
var2.appendTag(var4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue