Created
September 8, 2013 16:59
-
-
Save mak326428/6486436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package makmods.levelstorage.item; | |
import ic2.api.item.IElectricItem; | |
import makmods.levelstorage.LevelStorageCreativeTab; | |
import net.minecraft.client.renderer.texture.IconRegister; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.world.World; | |
import cpw.mods.fml.common.FMLCommonHandler; | |
import cpw.mods.fml.relauncher.Side; | |
import cpw.mods.fml.relauncher.SideOnly; | |
/** | |
* Provides basic functions for easier electric items implementation | |
* @author mak326428 | |
* | |
*/ | |
public abstract class ItemBasicElectric extends Item implements IElectricItem { | |
private int storage; | |
private int tier; | |
private int transferLimit; | |
private String texture; | |
/** | |
* <p> | |
* Called upon item gets clicked on a block | |
* </p> | |
* <p> | |
* It is only called on simulating side (server), so you don't need to check | |
* for !world.isRemote | |
* </p> | |
* | |
* @param item | |
* ItemStack representing the item | |
* @param world | |
* World (can be safely casted to WorldServer, if needed) | |
* @param player | |
* EntityPlayer (can be safely casted to EntityPlayerMP, if needed) | |
*/ | |
public abstract void onBlockClick(ItemStack item, World world, | |
EntityPlayer player); | |
/** | |
* <p> | |
* Called upon item gets right clicked (not on a block) | |
* </p> | |
* <p> | |
* It is only called on simulating side (server), so you don't need to check | |
* for !world.isRemote | |
* </p> | |
* | |
* @param item | |
* ItemStack representing the item | |
* @param world | |
* World (can be safely casted to WorldServer, if needed) | |
* @param player | |
* EntityPlayer (can be safely casted to EntityPlayerMP, if needed) | |
*/ | |
public abstract void onRightClick(ItemStack item, World world, | |
EntityPlayer player); | |
public ItemBasicElectric(int id, int tier, int storage, int transferLimit, | |
String texture) { | |
super(id); | |
this.setMaxDamage(27); | |
this.setNoRepair(); | |
if (FMLCommonHandler.instance().getSide().isClient()) { | |
this.setCreativeTab(LevelStorageCreativeTab.instance); | |
} | |
this.setMaxStackSize(1); | |
this.storage = storage; | |
this.tier = tier; | |
this.transferLimit = transferLimit; | |
this.texture = texture; | |
} | |
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, | |
EntityPlayer par3EntityPlayer) { | |
if (!par2World.isRemote) | |
onRightClick(par1ItemStack, par2World, par3EntityPlayer); | |
return par1ItemStack; | |
} | |
public boolean onItemUse(ItemStack par1ItemStack, | |
EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, | |
int par6, int par7, float par8, float par9, float par10) { | |
if (!par3World.isRemote) | |
onBlockClick(par1ItemStack, par3World, par2EntityPlayer); | |
return false; | |
} | |
@Override | |
public boolean canProvideEnergy(ItemStack itemStack) { | |
return false; | |
} | |
@Override | |
public int getChargedItemId(ItemStack itemStack) { | |
return this.itemID; | |
} | |
@Override | |
public int getEmptyItemId(ItemStack itemStack) { | |
return this.itemID; | |
} | |
@Override | |
public int getMaxCharge(ItemStack itemStack) { | |
return this.storage; | |
} | |
@Override | |
public int getTier(ItemStack itemStack) { | |
return this.tier; | |
} | |
@Override | |
public int getTransferLimit(ItemStack itemStack) { | |
return this.transferLimit; | |
} | |
@Override | |
@SideOnly(Side.CLIENT) | |
public void registerIcons(IconRegister iconRegister) { | |
this.itemIcon = iconRegister.registerIcon(texture); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment