creative storage cell

This commit is contained in:
Raoul Van den Berge
2015-12-13 20:29:04 +01:00
parent 129e5a5428
commit 455ec9dd47
2 changed files with 20 additions and 9 deletions

View File

@@ -30,18 +30,18 @@ public class ItemStorageCell extends ItemSC {
@Override @Override
public void getSubItems(Item item, CreativeTabs tab, List list) { public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 5; ++i) {
ItemStack cell = new ItemStack(item, 1, i); list.add(init(new ItemStack(item, 1, i)));
init(cell);
list.add(cell);
} }
} }
@Override @Override
public void addInformation(ItemStack cell, EntityPlayer player, List list, boolean b) { public void addInformation(ItemStack cell, EntityPlayer player, List list, boolean b) {
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storageCellStored"), getStored(cell), getCapacity(cell))); if (getCapacity(cell) == -1) {
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storageCellStored"), getStored(cell)));
} else {
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storageCellStoredWithCapacity"), getStored(cell), getCapacity(cell)));
}
} }
@Override @Override
@@ -67,10 +67,12 @@ public class ItemStorageCell extends ItemSC {
return items; return items;
} }
public static void init(ItemStack cell) { public static ItemStack init(ItemStack cell) {
cell.stackTagCompound = new NBTTagCompound(); cell.stackTagCompound = new NBTTagCompound();
cell.stackTagCompound.setTag(NBT_ITEMS, new NBTTagList()); cell.stackTagCompound.setTag(NBT_ITEMS, new NBTTagList());
cell.stackTagCompound.setInteger(NBT_STORED, 0); cell.stackTagCompound.setInteger(NBT_STORED, 0);
return cell;
} }
public static void push(ItemStack cell, ItemStack stack) { public static void push(ItemStack cell, ItemStack stack) {
@@ -128,6 +130,10 @@ public class ItemStorageCell extends ItemSC {
} }
public static boolean hasSpace(ItemStack cell, ItemStack stack) { public static boolean hasSpace(ItemStack cell, ItemStack stack) {
if (getCapacity(cell) == -1) {
return true;
}
return (getStored(cell) + stack.stackSize) <= getCapacity(cell); return (getStored(cell) + stack.stackSize) <= getCapacity(cell);
} }
@@ -145,6 +151,8 @@ public class ItemStorageCell extends ItemSC {
return 16000; return 16000;
case 3: case 3:
return 64000; return 64000;
case 4:
return -1;
} }
return 0; return 0;

View File

@@ -6,7 +6,9 @@ gui.storagecraft:drive=Drive
misc.storagecraft:energyStored=%d / %d RF misc.storagecraft:energyStored=%d / %d RF
misc.storagecraft:energyUsage=Energy Usage: %d RF/t misc.storagecraft:energyUsage=Energy Usage: %d RF/t
misc.storagecraft:storageCellStored=Stored: %d / %d
misc.storagecraft:storageCellStored=Stored: %d
misc.storagecraft:storageCellStoredWithCapacity=Stored: %d / %d
block.storagecraft:controller.name=Controller block.storagecraft:controller.name=Controller
block.storagecraft:cable.name=Cable block.storagecraft:cable.name=Cable
@@ -18,3 +20,4 @@ item.storagecraft:storageCell.0.name=1k Storage Cell
item.storagecraft:storageCell.1.name=4k Storage Cell item.storagecraft:storageCell.1.name=4k Storage Cell
item.storagecraft:storageCell.2.name=16k Storage Cell item.storagecraft:storageCell.2.name=16k Storage Cell
item.storagecraft:storageCell.3.name=64k Storage Cell item.storagecraft:storageCell.3.name=64k Storage Cell
item.storagecraft:storageCell.4.name=Creative Storage Cell