Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MultiTech;
- import java.util.List;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import ic2.api.ElectricItem;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.EnumAction;
- import net.minecraft.item.ItemFood;
- import net.minecraft.item.ItemStack;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.world.World;
- import ic2.api.ElectricItem;
- import ic2.api.IElectricItem;
- import net.minecraft.item.*;
- public class ItemUUFood extends ItemFood implements IElectricItem
- {
- public int mCharge, mTransfer, mTier;
- /** Number of ticks to run while 'EnumAction'ing until result. */
- public final int itemUseDuration;
- /** The amount this food item heals the player. */
- private final int healAmount;
- private final float saturationModifier;
- /** Whether wolves like this food (true for raw and cooked porkchop). */
- private final boolean isWolfsFavoriteMeat;
- /**
- * If this field is true, the food can be consumed even if the player don't need to eat.
- */
- private boolean alwaysEdible;
- /**
- * represents the potion effect that will occurr upon eating this food. Set by setPotionEffect
- */
- private int potionId;
- /** set by setPotionEffect */
- private int potionDuration;
- /** set by setPotionEffect */
- private int potionAmplifier;
- /** probably of the set potion effect occurring */
- private float potionEffectProbability;
- public ItemUUFood(int par1, int par2, float par3, boolean par4)
- {
- super(par1, par2, par3, par4);
- this.itemUseDuration = 32;
- this.healAmount = par2;
- this.isWolfsFavoriteMeat = par4;
- this.saturationModifier = par3;
- this.setCreativeTab(CreativeTabs.tabFood);
- this.setNoRepair();
- this.setMaxStackSize(1);
- setMaxDamage(100);
- setNoRepair();
- mCharge = 100000;
- mTransfer = 512;
- mTier = 1;
- }
- public String getTextureFile()
- {
- return CommonProxy.ITEMS_PNG;
- }
- public ItemUUFood(int par1, int par2, boolean par3)
- {
- this(par1, par2, 0.6F, par3);
- }
- public ItemStack onFoodEaten(ItemStack var1, World var2, int var3, int var4, int var5, int var6, EntityLiving var7, EntityPlayer var8)
- {
- var8.getFoodStats().addStats(this);
- var2.playSoundAtEntity(var8, "random.burp", 0.5F, var2.rand.nextFloat() * 0.1F + 0.9F);
- if (var8 instanceof EntityPlayer) {
- ElectricItem.use(var1, 500, (EntityPlayer)var8);
- } else {
- ElectricItem.discharge(var1, 500, mTier, true, false);
- }
- return var1;
- }
- protected void func_77849_c(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
- {
- if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability)
- {
- par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
- }
- }
- /**
- * How long it takes to use or consume an item
- */
- @Override
- public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float var8, float var9, float var10) {
- ElectricItem.use(aStack, 0, aPlayer);
- return true;
- }
- @Override
- public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
- }
- @Override
- public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
- return false;
- }
- public int getMaxItemUseDuration(ItemStack par1ItemStack)
- {
- return 32;
- }
- /**
- * returns the action that specifies what animation to play when the items is being used
- */
- public EnumAction getItemUseAction(ItemStack par1ItemStack)
- {
- return EnumAction.eat;
- }
- /**
- * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
- */
- public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
- {
- if (par3EntityPlayer.canEat(this.alwaysEdible))
- {
- par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
- }
- return par1ItemStack;
- }
- public int getHealAmount()
- {
- return this.healAmount;
- }
- /**
- * gets the saturationModifier of the ItemFood
- */
- public float getSaturationModifier()
- {
- return this.saturationModifier;
- }
- /**
- * Whether wolves like this food (true for raw and cooked porkchop).
- */
- public boolean isWolfsFavoriteMeat()
- {
- return this.isWolfsFavoriteMeat;
- }
- /**
- * sets a potion effect on the item. Args: int potionId, int duration (will be multiplied by 20), int amplifier,
- * float probability of effect happening
- */
- public ItemUUFood setPotionEffect(int par1, int par2, int par3, float par4)
- {
- this.potionId = par1;
- this.potionDuration = par2;
- this.potionAmplifier = par3;
- this.potionEffectProbability = par4;
- return this;
- }
- /**
- * Set the field 'alwaysEdible' to true, and make the food edible even if the player don't need to eat.
- */
- public ItemUUFood setAlwaysEdible()
- {
- this.alwaysEdible = true;
- return this;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void getSubItems(int var1, CreativeTabs var2, List var3) {
- ItemStack tCharged = new ItemStack(this, 1), tUncharged = new ItemStack(this, 1, getMaxDamage());
- ElectricItem.charge(tCharged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false);
- var3.add(tCharged);
- var3.add(tUncharged);
- }
- @Override
- public boolean getShareTag() {
- return true;
- }
- @Override
- public boolean canProvideEnergy() {
- return false;
- }
- @Override
- public int getChargedItemId() {
- return itemID;
- }
- @Override
- public int getEmptyItemId() {
- return itemID;
- }
- @Override
- public int getMaxCharge() {
- return mCharge;
- }
- @Override
- public int getTier() {
- return mTier;
- }
- @Override
- public int getTransferLimit() {
- return mTransfer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement