This commit is contained in:
Raoul Van den Berge
2015-12-22 12:39:03 +01:00
parent da89f6778e
commit 3b143310e3
76 changed files with 1730 additions and 847 deletions

View File

@@ -4,10 +4,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import storagecraft.StorageCraft;
public abstract class ItemBase extends Item {
public abstract class ItemBase extends Item
{
private String name;
public ItemBase(String name) {
public ItemBase(String name)
{
this.name = name;
setCreativeTab(StorageCraft.TAB);
@@ -15,13 +17,16 @@ public abstract class ItemBase extends Item {
}
@Override
public String getUnlocalizedName() {
public String getUnlocalizedName()
{
return "item." + StorageCraft.ID + ":" + name;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
if (getHasSubtypes()) {
public String getUnlocalizedName(ItemStack stack)
{
if (getHasSubtypes())
{
return getUnlocalizedName() + "." + stack.getItemDamage();
}

View File

@@ -4,13 +4,16 @@ import net.minecraft.block.Block;
import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
public abstract class ItemBlockBase extends ItemBlockWithMetadata {
public ItemBlockBase(Block block) {
public abstract class ItemBlockBase extends ItemBlockWithMetadata
{
public ItemBlockBase(Block block)
{
super(block, block);
}
@Override
public String getUnlocalizedName(ItemStack stack) {
public String getUnlocalizedName(ItemStack stack)
{
return getUnlocalizedName() + "." + stack.getItemDamage();
}
}

View File

@@ -2,8 +2,10 @@ package storagecraft.item;
import net.minecraft.block.Block;
public class ItemBlockCable extends ItemBlockBase {
public ItemBlockCable(Block block) {
public class ItemBlockCable extends ItemBlockBase
{
public ItemBlockCable(Block block)
{
super(block);
}
}

View File

@@ -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: