Fixed Quantum Chest/Digital Chest stored items closes #247
This commit is contained in:
parent
9b6383a548
commit
c2dcaf1902
4 changed files with 125 additions and 92 deletions
|
@ -40,7 +40,8 @@ public class GuiDigitalChest extends GuiContainer {
|
||||||
this.ySize - 96 + 2, 4210752);
|
this.ySize - 96 + 2, 4210752);
|
||||||
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
|
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
|
||||||
if (tile.storedItem != null)
|
if (tile.storedItem != null)
|
||||||
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10,
|
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, 30, 16448255);
|
||||||
30, 16448255);
|
if (tile.storedItem == null && tile.getStackInSlot(1) != null)
|
||||||
|
this.fontRendererObj.drawString(tile.getStackInSlot(1).stackSize + "", 10, 30, 16448255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class GuiQuantumChest extends GuiContainer {
|
||||||
this.ySize - 96 + 2, 4210752);
|
this.ySize - 96 + 2, 4210752);
|
||||||
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
|
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
|
||||||
if (tile.storedItem != null && tile.getStackInSlot(1) != null)
|
if (tile.storedItem != null && tile.getStackInSlot(1) != null)
|
||||||
this.fontRendererObj.drawString(tile.storedItem.stackSize + tile.getStackInSlot(1).stackSize + "", 10,
|
this.fontRendererObj.drawString(tile.storedItem.stackSize + tile.getStackInSlot(1).stackSize + "", 10, 30, 16448255);
|
||||||
30, 16448255);
|
if (tile.storedItem == null && tile.getStackInSlot(1) != null)
|
||||||
|
this.fontRendererObj.drawString(tile.getStackInSlot(1).stackSize + "", 10, 30, 16448255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,51 +30,67 @@ public class TileDigitalChest extends TileMachineBase implements IInventory,
|
||||||
|
|
||||||
public ItemStack storedItem;
|
public ItemStack storedItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity()
|
||||||
if (!worldObj.isRemote) {
|
{
|
||||||
if (storedItem != null) {
|
if (!worldObj.isRemote)
|
||||||
ItemStack fakeStack = storedItem.copy();
|
{
|
||||||
fakeStack.stackSize = 1;
|
if (storedItem != null)
|
||||||
setInventorySlotContents(2, fakeStack);
|
{
|
||||||
} else {
|
ItemStack fakeStack = storedItem.copy();
|
||||||
setInventorySlotContents(2, null);
|
fakeStack.stackSize = 1;
|
||||||
}
|
setInventorySlotContents(2, fakeStack);
|
||||||
|
}
|
||||||
|
else if (storedItem == null && getStackInSlot(1) != null)
|
||||||
|
{
|
||||||
|
ItemStack fakeStack = getStackInSlot(1).copy();
|
||||||
|
fakeStack.stackSize = 1;
|
||||||
|
setInventorySlotContents(2, fakeStack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setInventorySlotContents(2, null);
|
||||||
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0) != null) {
|
if (getStackInSlot(0) != null)
|
||||||
if (storedItem == null) {
|
{
|
||||||
storedItem = getStackInSlot(0);
|
if (storedItem == null && getStackInSlot(1) == null)
|
||||||
setInventorySlotContents(0, null);
|
{
|
||||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0),
|
storedItem = getStackInSlot(0);
|
||||||
true, true)) {
|
setInventorySlotContents(0, null);
|
||||||
if (storedItem.stackSize <= Integer.MAX_VALUE
|
}
|
||||||
- getStackInSlot(0).stackSize) {
|
else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true))
|
||||||
storedItem.stackSize += getStackInSlot(0).stackSize;
|
{
|
||||||
decrStackSize(0, getStackInSlot(0).stackSize);
|
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize)
|
||||||
}
|
{
|
||||||
}
|
storedItem.stackSize += getStackInSlot(0).stackSize;
|
||||||
}
|
decrStackSize(0, getStackInSlot(0).stackSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (storedItem != null && getStackInSlot(1) == null) {
|
if (storedItem != null && getStackInSlot(1) == null)
|
||||||
ItemStack itemStack = storedItem.copy();
|
{
|
||||||
itemStack.stackSize = itemStack.getMaxStackSize();
|
ItemStack itemStack = storedItem.copy();
|
||||||
setInventorySlotContents(1, itemStack);
|
itemStack.stackSize = itemStack.getMaxStackSize();
|
||||||
storedItem.stackSize -= itemStack.getMaxStackSize();
|
setInventorySlotContents(1, itemStack);
|
||||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true,
|
storedItem.stackSize -= itemStack.getMaxStackSize();
|
||||||
true)) {
|
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true))
|
||||||
int wanted = getStackInSlot(1).getMaxStackSize()
|
{
|
||||||
- getStackInSlot(1).stackSize;
|
int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize;
|
||||||
if (storedItem.stackSize >= wanted) {
|
if (storedItem.stackSize >= wanted)
|
||||||
decrStackSize(1, -wanted);
|
{
|
||||||
storedItem.stackSize -= wanted;
|
decrStackSize(1, -wanted);
|
||||||
} else {
|
storedItem.stackSize -= wanted;
|
||||||
decrStackSize(1, -storedItem.stackSize);
|
} else
|
||||||
storedItem = null;
|
{
|
||||||
}
|
decrStackSize(1, -storedItem.stackSize);
|
||||||
}
|
storedItem = null;
|
||||||
}
|
}
|
||||||
syncWithAll();
|
}
|
||||||
}
|
}
|
||||||
|
syncWithAll();
|
||||||
|
}
|
||||||
|
|
||||||
public Packet getDescriptionPacket() {
|
public Packet getDescriptionPacket() {
|
||||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||||
|
|
|
@ -26,56 +26,71 @@ public class TileQuantumChest extends TileMachineBase implements IInventory,
|
||||||
//TODO use long so we can have 9,223,372,036,854,775,807 items instead of 2,147,483,647
|
//TODO use long so we can have 9,223,372,036,854,775,807 items instead of 2,147,483,647
|
||||||
int storage = (int) Double.MAX_VALUE;
|
int storage = (int) Double.MAX_VALUE;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(3, "TileQuantumChest",
|
public Inventory inventory = new Inventory(3, "TileQuantumChest", storage);
|
||||||
storage);
|
|
||||||
|
|
||||||
public ItemStack storedItem;
|
public ItemStack storedItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity()
|
||||||
if (!worldObj.isRemote) {
|
{
|
||||||
if (storedItem != null) {
|
if (!worldObj.isRemote)
|
||||||
ItemStack fakeStack = storedItem.copy();
|
{
|
||||||
fakeStack.stackSize = 1;
|
if (storedItem != null)
|
||||||
setInventorySlotContents(2, fakeStack);
|
{
|
||||||
} else {
|
ItemStack fakeStack = storedItem.copy();
|
||||||
setInventorySlotContents(2, null);
|
fakeStack.stackSize = 1;
|
||||||
}
|
setInventorySlotContents(2, fakeStack);
|
||||||
|
}
|
||||||
|
else if (storedItem == null && getStackInSlot(1) != null)
|
||||||
|
{
|
||||||
|
ItemStack fakeStack = getStackInSlot(1).copy();
|
||||||
|
fakeStack.stackSize = 1;
|
||||||
|
setInventorySlotContents(2, fakeStack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setInventorySlotContents(2, null);
|
||||||
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0) != null) {
|
if (getStackInSlot(0) != null)
|
||||||
if (storedItem == null) {
|
{
|
||||||
storedItem = getStackInSlot(0);
|
if (storedItem == null && getStackInSlot(1) == null)
|
||||||
setInventorySlotContents(0, null);
|
{
|
||||||
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0),
|
storedItem = getStackInSlot(0);
|
||||||
true, true)) {
|
setInventorySlotContents(0, null);
|
||||||
if (storedItem.stackSize <= Integer.MAX_VALUE
|
}
|
||||||
- getStackInSlot(0).stackSize) {
|
else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true))
|
||||||
storedItem.stackSize += getStackInSlot(0).stackSize;
|
{
|
||||||
decrStackSize(0, getStackInSlot(0).stackSize);
|
if (storedItem.stackSize <= storage - getStackInSlot(0).stackSize)
|
||||||
}
|
{
|
||||||
}
|
storedItem.stackSize += getStackInSlot(0).stackSize;
|
||||||
}
|
decrStackSize(0, getStackInSlot(0).stackSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (storedItem != null && getStackInSlot(1) == null) {
|
if (storedItem != null && getStackInSlot(1) == null)
|
||||||
ItemStack itemStack = storedItem.copy();
|
{
|
||||||
itemStack.stackSize = itemStack.getMaxStackSize();
|
ItemStack itemStack = storedItem.copy();
|
||||||
setInventorySlotContents(1, itemStack);
|
itemStack.stackSize = itemStack.getMaxStackSize();
|
||||||
storedItem.stackSize -= itemStack.getMaxStackSize();
|
setInventorySlotContents(1, itemStack);
|
||||||
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true,
|
storedItem.stackSize -= itemStack.getMaxStackSize();
|
||||||
true)) {
|
} else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true))
|
||||||
int wanted = getStackInSlot(1).getMaxStackSize()
|
{
|
||||||
- getStackInSlot(1).stackSize;
|
int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize;
|
||||||
if (storedItem.stackSize >= wanted) {
|
if (storedItem.stackSize >= wanted)
|
||||||
decrStackSize(1, -wanted);
|
{
|
||||||
storedItem.stackSize -= wanted;
|
decrStackSize(1, -wanted);
|
||||||
} else {
|
storedItem.stackSize -= wanted;
|
||||||
decrStackSize(1, -storedItem.stackSize);
|
} else
|
||||||
storedItem = null;
|
{
|
||||||
}
|
decrStackSize(1, -storedItem.stackSize);
|
||||||
}
|
storedItem = null;
|
||||||
}
|
}
|
||||||
syncWithAll();
|
}
|
||||||
}
|
}
|
||||||
|
syncWithAll();
|
||||||
|
}
|
||||||
|
|
||||||
public Packet getDescriptionPacket() {
|
public Packet getDescriptionPacket() {
|
||||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||||
|
|
Loading…
Reference in a new issue