2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("ItemJams.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2015-11-02 20:55:19 +01:00
|
|
|
* © 2015 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2015-04-06 15:51:59 +02:00
|
|
|
package ellpeck.actuallyadditions.items;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-12-03 20:15:07 +01:00
|
|
|
import ellpeck.actuallyadditions.items.base.ItemFoodBase;
|
2015-04-06 15:51:59 +02:00
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheJams;
|
2015-08-28 22:18:46 +02:00
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-11-23 19:06:07 +01:00
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-04-06 15:51:59 +02:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public class ItemJams extends ItemFoodBase{
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
public static final TheJams[] allJams = TheJams.values();
|
2015-10-28 14:46:04 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-04-06 15:51:59 +02:00
|
|
|
public IIcon overlayIcon;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public ItemJams(String name){
|
|
|
|
super(0, 0.0F, false, name);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
2015-12-10 14:37:56 +01:00
|
|
|
this.setAlwaysEdible();
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public int getMetadata(int damage){
|
|
|
|
return damage;
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2015-11-23 19:06:07 +01:00
|
|
|
return stack.getItemDamage() >= allJams.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allJams[stack.getItemDamage()].name;
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public int getColorFromItemStack(ItemStack stack, int pass){
|
|
|
|
return pass > 0 ? (stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].color) : super.getColorFromItemStack(stack, pass);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
return stack.getItemDamage() >= allJams.length ? EnumRarity.common : allJams[stack.getItemDamage()].rarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean requiresMultipleRenderPasses(){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IIcon getIconFromDamageForRenderPass(int damage, int pass){
|
|
|
|
return pass > 0 ? this.overlayIcon : super.getIconFromDamageForRenderPass(damage, pass);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubItems(Item item, CreativeTabs tab, List list){
|
2015-10-02 16:48:01 +02:00
|
|
|
for(int j = 0; j < allJams.length; j++){
|
2015-04-06 15:51:59 +02:00
|
|
|
list.add(new ItemStack(this, 1, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerIcons(IIconRegister iconReg){
|
2015-12-03 20:15:07 +01:00
|
|
|
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
|
|
|
|
this.overlayIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Overlay");
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){
|
|
|
|
ItemStack stackToReturn = super.onEaten(stack, world, player);
|
|
|
|
|
2015-06-12 19:12:06 +02:00
|
|
|
if(!world.isRemote && stack.getItemDamage() < allJams.length){
|
2015-04-19 01:50:02 +02:00
|
|
|
PotionEffect firstEffectToGet = new PotionEffect(allJams[stack.getItemDamage()].firstEffectToGet, 200);
|
|
|
|
player.addPotionEffect(firstEffectToGet);
|
|
|
|
|
|
|
|
PotionEffect secondEffectToGet = new PotionEffect(allJams[stack.getItemDamage()].secondEffectToGet, 600);
|
|
|
|
player.addPotionEffect(secondEffectToGet);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
ItemStack returnItem = new ItemStack(Items.glass_bottle);
|
|
|
|
if(!player.inventory.addItemStackToInventory(returnItem.copy())){
|
|
|
|
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy());
|
|
|
|
entityItem.delayBeforeCanPickup = 0;
|
|
|
|
player.worldObj.spawnEntityInWorld(entityItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stackToReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public int func_150905_g(ItemStack stack){
|
|
|
|
return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].healAmount;
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public float func_150906_h(ItemStack stack){
|
|
|
|
return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].saturation;
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
}
|