reformat
This commit is contained in:
@@ -13,10 +13,12 @@ import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import storagecraft.storage.CellStorage;
|
||||
|
||||
public class ItemStorageCell extends ItemBase {
|
||||
public class ItemStorageCell extends ItemBase
|
||||
{
|
||||
private IIcon[] icons = new IIcon[5];
|
||||
|
||||
public ItemStorageCell() {
|
||||
public ItemStorageCell()
|
||||
{
|
||||
super("storageCell");
|
||||
|
||||
setMaxStackSize(1);
|
||||
@@ -25,41 +27,52 @@ public class ItemStorageCell extends ItemBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
list.add(initNBT(new ItemStack(item, 1, i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack cell, EntityPlayer player, List list, boolean b) {
|
||||
if (getCapacity(cell) == -1) {
|
||||
public void addInformation(ItemStack cell, EntityPlayer player, List list, boolean b)
|
||||
{
|
||||
if (getCapacity(cell) == -1)
|
||||
{
|
||||
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storageCellStored"), getStored(cell)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storageCellStoredWithCapacity"), getStored(cell), getCapacity(cell)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
super.onCreated(stack, world, player);
|
||||
|
||||
initNBT(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
public void registerIcons(IIconRegister register)
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
icons[i] = register.registerIcon("storagecraft:storageCell" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
public IIcon getIconFromDamage(int damage)
|
||||
{
|
||||
return icons[damage];
|
||||
}
|
||||
|
||||
private ItemStack initNBT(ItemStack cell) {
|
||||
private ItemStack initNBT(ItemStack cell)
|
||||
{
|
||||
cell.stackTagCompound = new NBTTagCompound();
|
||||
cell.stackTagCompound.setTag(CellStorage.NBT_ITEMS, new NBTTagList());
|
||||
cell.stackTagCompound.setInteger(CellStorage.NBT_STORED, 0);
|
||||
@@ -67,12 +80,15 @@ public class ItemStorageCell extends ItemBase {
|
||||
return cell;
|
||||
}
|
||||
|
||||
public static int getStored(ItemStack cell) {
|
||||
public static int getStored(ItemStack cell)
|
||||
{
|
||||
return cell.stackTagCompound.getInteger(CellStorage.NBT_STORED);
|
||||
}
|
||||
|
||||
public static int getCapacity(ItemStack cell) {
|
||||
switch (cell.getItemDamage()) {
|
||||
public static int getCapacity(ItemStack cell)
|
||||
{
|
||||
switch (cell.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
return 1000;
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user