add meta object to storage items
This commit is contained in:
@@ -141,7 +141,7 @@ public class TileController extends TileSC implements IEnergyReceiver, INetworkT
|
||||
|
||||
StorageItem other = items.get(j);
|
||||
|
||||
if (item.equalsIgnoreQuantity(other)) {
|
||||
if (item.getMeta().equals(other.getMeta())) {
|
||||
item.setQuantity(item.getQuantity() + other.getQuantity());
|
||||
|
||||
markedIndexes.add(j);
|
||||
@@ -255,10 +255,10 @@ public class TileController extends TileSC implements IEnergyReceiver, INetworkT
|
||||
for (int i = 0; i < size; ++i) {
|
||||
Item type = Item.getItemById(buf.readInt());
|
||||
int quantity = buf.readInt();
|
||||
int meta = buf.readInt();
|
||||
int damage = buf.readInt();
|
||||
NBTTagCompound tag = buf.readBoolean() ? ByteBufUtils.readTag(buf) : null;
|
||||
|
||||
items.add(new StorageItem(type, quantity, meta, tag));
|
||||
items.add(new StorageItem(type, quantity, damage, tag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,13 +270,13 @@ public class TileController extends TileSC implements IEnergyReceiver, INetworkT
|
||||
buf.writeInt(items.size());
|
||||
|
||||
for (StorageItem item : items) {
|
||||
buf.writeInt(Item.getIdFromItem(item.getType()));
|
||||
buf.writeInt(Item.getIdFromItem(item.getMeta().getType()));
|
||||
buf.writeInt(item.getQuantity());
|
||||
buf.writeInt(item.getMeta());
|
||||
buf.writeBoolean(item.getTag() != null);
|
||||
buf.writeInt(item.getMeta().getDamage());
|
||||
buf.writeBoolean(item.getMeta().getTag() != null);
|
||||
|
||||
if (item.getTag() != null) {
|
||||
ByteBufUtils.writeTag(buf, item.getTag());
|
||||
if (item.getMeta().getTag() != null) {
|
||||
ByteBufUtils.writeTag(buf, item.getMeta().getTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import storagecraft.SC;
|
||||
import storagecraft.inventory.InventorySC;
|
||||
import storagecraft.storage.CellStorage;
|
||||
import storagecraft.storage.IStorage;
|
||||
import storagecraft.storage.IStorageProvider;
|
||||
import storagecraft.util.InventoryUtil;
|
||||
|
||||
public class TileDrive extends TileMachine implements IInventory, IStorageProvider {
|
||||
private InventorySC inventory = new InventorySC("drive", 8);
|
||||
@@ -91,14 +91,14 @@ public class TileDrive extends TileMachine implements IInventory, IStorageProvid
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
SC.restoreInventory(this, nbt);
|
||||
InventoryUtil.restoreInventory(this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
SC.saveInventory(this, nbt);
|
||||
InventoryUtil.saveInventory(this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import storagecraft.storage.IStorage;
|
||||
import storagecraft.storage.IStorageProvider;
|
||||
import storagecraft.storage.StorageItem;
|
||||
import storagecraft.util.InventoryUtil;
|
||||
|
||||
public class TileStorageProxy extends TileMachine implements IStorageProvider, IStorage {
|
||||
private IInventory inventory;
|
||||
@@ -57,7 +58,7 @@ public class TileStorageProxy extends TileMachine implements IStorageProvider, I
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
|
||||
return;
|
||||
} else if (StorageItem.equalsIgnoreQuantity(slot, stack)) {
|
||||
} else if (InventoryUtil.equalsIgnoreQuantity(slot, stack)) {
|
||||
int toAdd = toGo;
|
||||
|
||||
if (slot.stackSize + toAdd > slot.getMaxStackSize()) {
|
||||
@@ -86,7 +87,7 @@ public class TileStorageProxy extends TileMachine implements IStorageProvider, I
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null && StorageItem.equalsIgnoreQuantity(slot, stack)) {
|
||||
if (slot != null && InventoryUtil.equalsIgnoreQuantity(slot, stack)) {
|
||||
if (quantity > slot.stackSize) {
|
||||
quantity = slot.stackSize;
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class TileStorageProxy extends TileMachine implements IStorageProvider, I
|
||||
|
||||
if (slot == null) {
|
||||
return true;
|
||||
} else if (StorageItem.equalsIgnoreQuantity(slot, stack)) {
|
||||
} else if (InventoryUtil.equalsIgnoreQuantity(slot, stack)) {
|
||||
int toAdd = toGo;
|
||||
|
||||
if (slot.stackSize + toAdd > slot.getMaxStackSize()) {
|
||||
|
||||
Reference in New Issue
Block a user