Search in sources :

Example 11 with ItemFood

use of net.minecraft.item.ItemFood in project FoodCraft-Reloaded by LasmGratel.

the class RegisterLoader method detectAndRegisterLiqueur.

public void detectAndRegisterLiqueur(RegistryEvent.Register<Item> event) {
    event.getRegistry().getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()).forEach(liqueur -> {
        for (LiqueurType liqueurType : LiqueurTypes.values()) {
            if (liqueurType == LiqueurTypes.NORMAL)
                continue;
            ItemGeneratedLiqueur typedLiqueur = new ItemGeneratedLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
            typedLiqueur.setLiqueurType(liqueurType);
            typedLiqueur.setItemStackDisplayNameCallback(liqueur::getItemStackDisplayName);
            typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
            typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
            event.getRegistry().register(typedLiqueur);
            OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
            OreDictionary.registerOre("listAllliqueur", typedLiqueur);
            OreDictionary.registerOre("listAllfoods", typedLiqueur);
            if (liqueur instanceof CustomModelMasking)
                FoodCraftReloadedMod.getLoader(LiqueurLoader.class).get().getLiqueurCustomModelMap().put(typedLiqueur, (CustomModelMasking) liqueur);
        }
    });
}
Also used : ItemGeneratedLiqueur(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemGeneratedLiqueur) Item(net.minecraft.item.Item) LiqueurTypes(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurTypes) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) ItemFood(net.minecraft.item.ItemFood) FoodCraftReloadedMod(cc.lasmgratel.foodcraftreloaded.minecraft.common.FoodCraftReloadedMod) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) LiqueurType(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurType) ItemStack(net.minecraft.item.ItemStack) MinecraftForge(net.minecraftforge.common.MinecraftForge) Load(cc.lasmgratel.foodcraftreloaded.minecraft.common.util.loader.annotation.Load) LoaderState(net.minecraftforge.fml.common.LoaderState) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) MathHelper(net.minecraft.util.math.MathHelper) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RegistryEvent(net.minecraftforge.event.RegistryEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) LiqueurLoader(cc.lasmgratel.foodcraftreloaded.minecraft.common.loader.LiqueurLoader) ItemGeneratedLiqueur(cc.lasmgratel.foodcraftreloaded.minecraft.common.item.food.ItemGeneratedLiqueur) CustomModelMasking(cc.lasmgratel.foodcraftreloaded.minecraft.client.util.masking.CustomModelMasking) LiqueurType(cc.lasmgratel.foodcraftreloaded.minecraft.api.capability.liqueur.LiqueurType) ItemStack(net.minecraft.item.ItemStack)

Example 12 with ItemFood

use of net.minecraft.item.ItemFood in project BiomesOPlenty by Glitchfiend.

the class ModItems method registerItems.

public static void registerItems() {
    jar_filled = registerItem(new ItemJarFilled(), "jar_filled");
    jar_empty = registerItem(new ItemJarEmpty(), "jar_empty");
    boat_sacred_oak = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.SACRED_OAK), "boat_sacred_oak");
    boat_cherry = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.CHERRY), "boat_cherry");
    boat_umbran = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.UMBRAN), "boat_umbran");
    boat_fir = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.FIR), "boat_fir");
    boat_ethereal = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.ETHEREAL), "boat_ethereal");
    boat_magic = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.MAGIC), "boat_magic");
    boat_mangrove = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.MANGROVE), "boat_mangrove");
    boat_palm = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.PALM), "boat_palm");
    boat_redwood = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.REDWOOD), "boat_redwood");
    boat_willow = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.WILLOW), "boat_willow");
    boat_pine = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.PINE), "boat_pine");
    boat_hellbark = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.HELLBARK), "boat_hellbark");
    boat_jacaranda = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.JACARANDA), "boat_jacaranda");
    boat_mahogany = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.MAHOGANY), "boat_mahogany");
    boat_ebony = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.EBONY), "boat_ebony");
    boat_eucalyptus = registerItem(new ItemBOPBoat(EntityBOPBoat.Type.EUCALYPTUS), "boat_eucalyptus");
    biome_finder = registerItem(new ItemBiomeFinder(), "biome_finder");
    flower_basket = registerItem(new ItemFlowerBasket(), "flower_basket");
    record_wanderer = registerItem(new ItemBOPRecord("wanderer", BOPSounds.records_wanderer), "record_wanderer");
    mudball = registerItem(new ItemMudball(), "mudball");
    mud_brick = registerItem(new Item(), "mud_brick");
    ash = registerItem(new Item(), "ash");
    fleshchunk = registerItem(new Item(), "fleshchunk");
    pixie_dust = registerItem(new Item(), "pixie_dust");
    gem = registerItem(new ItemGem(), "gem");
    terrestrial_artifact = registerItem(new Item(), "terrestrial_artifact");
    terrestrial_artifact.setMaxStackSize(1);
    crystal_shard = registerItem(new Item(), "crystal_shard");
    biome_essence = registerItem(new ItemBiomeEssence(), "biome_essence");
    // food
    berries = registerItem(new ItemBOPFood(1, 0.1F, 8), "berries");
    pear = registerItem(new ItemFood(5, 0.3F, false), "pear");
    peach = registerItem(new ItemFood(5, 0.2F, false), "peach");
    persimmon = registerItem(new ItemFood(5, 0.2F, false), "persimmon");
    pinecone = registerItem(new Item(), "pinecone");
    turnip_seeds = registerItem(new ItemSeeds(BOPBlocks.turnip_block, Blocks.FARMLAND), "turnip_seeds");
    turnip = registerItem(new ItemFood(3, 0.4F, false), "turnip");
    honeycomb = registerItem(new Item(), "honeycomb");
    filled_honeycomb = registerItem(new ItemBOPFood(3, 0.4F, 16), "filled_honeycomb");
    shroompowder = registerItem(new ItemFood(1, 0.1F, false), "shroompowder");
    ((ItemFood) shroompowder).setAlwaysEdible();
    ((ItemFood) shroompowder).setPotionEffect(new PotionEffect(MobEffects.NAUSEA, 225, 0), 1.0F);
    saladfruit = registerItem(new ItemSoup(6), "saladfruit");
    ((ItemFood) saladfruit).setPotionEffect(new PotionEffect(MobEffects.HASTE, 775, 1), 0.05F);
    saladveggie = registerItem(new ItemSoup(6), "saladveggie");
    // TODO: Is this the right potion effect for veggie salad?
    ((ItemFood) saladveggie).setPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 1100, 1), 0.05F);
    saladshroom = registerItem(new ItemSoup(6), "saladshroom");
    ((ItemFood) saladshroom).setPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 550, 1), 0.05F);
    ricebowl = registerItem(new ItemSoup(2), "ricebowl");
    ambrosia = registerItem(new ItemAmbrosia(), "ambrosia");
    // TODO: move dyes to their own class?
    blue_dye = registerItem(new Item(), "blue_dye");
    brown_dye = registerItem(new Item(), "brown_dye");
    green_dye = registerItem(new Item(), "green_dye");
    white_dye = registerItem(new Item(), "white_dye");
    black_dye = registerItem(new Item(), "black_dye");
    earth = registerItem(new Item(), "earth");
    earth.setCreativeTab(null);
}
Also used : ItemJarFilled(biomesoplenty.common.item.ItemJarFilled) ItemSoup(net.minecraft.item.ItemSoup) ItemJarEmpty(biomesoplenty.common.item.ItemJarEmpty) ItemAmbrosia(biomesoplenty.common.item.ItemAmbrosia) PotionEffect(net.minecraft.potion.PotionEffect) ItemGem(biomesoplenty.common.item.ItemGem) ItemBiomeEssence(biomesoplenty.common.item.ItemBiomeEssence) ItemSeeds(net.minecraft.item.ItemSeeds) Item(net.minecraft.item.Item) ItemFood(net.minecraft.item.ItemFood) ItemBiomeFinder(biomesoplenty.common.item.ItemBiomeFinder) ItemFlowerBasket(biomesoplenty.common.item.ItemFlowerBasket) ItemBOPRecord(biomesoplenty.common.item.ItemBOPRecord) ItemMudball(biomesoplenty.common.item.ItemMudball) ItemBOPBoat(biomesoplenty.common.item.ItemBOPBoat) ItemBOPFood(biomesoplenty.common.item.ItemBOPFood)

Example 13 with ItemFood

use of net.minecraft.item.ItemFood in project Minechem by iopleke.

the class PotionSpikingRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack foodItem = inv.getStackInSlot(i);
        if (foodItem != null && foodItem.getItem() instanceof ItemFood) {
            for (int j = 0; j < inv.getSizeInventory(); j++) {
                ItemStack moleculeStack = inv.getStackInSlot(j);
                if (moleculeStack != null && moleculeStack.getItem() instanceof MoleculeItem && PharmacologyEffectRegistry.hasEffect(MoleculeEnum.getById(moleculeStack.getItemDamage()))) {
                    ItemStack result = foodItem.copy();
                    result.stackSize = 1;
                    if (// empty NBT
                    result.stackTagCompound == null) {
                        NBTTagCompound tagCompound = new NBTTagCompound();
                        tagCompound.setBoolean("minechem.isPoisoned", true);
                        tagCompound.setIntArray("minechem.effectTypes", new int[] { MoleculeItem.getMolecule(moleculeStack).id() });
                        result.setTagCompound(tagCompound);
                    } else if (// has been poisoned before
                    result.stackTagCompound.hasKey("minechem.isPoisoned")) {
                        int[] arrayOld = result.stackTagCompound.getIntArray("minechem.effectTypes");
                        int[] arrayNew = new int[arrayOld.length + 1];
                        System.arraycopy(arrayOld, 0, arrayNew, 0, arrayOld.length);
                        arrayNew[arrayOld.length] = MoleculeItem.getMolecule(moleculeStack).id();
                        result.stackTagCompound.setIntArray("minechem.effectTypes", arrayNew);
                    } else // has NBT but no poison
                    {
                        result.stackTagCompound.setBoolean("minechem.isPoisoned", true);
                        result.stackTagCompound.setIntArray("minechem.effectTypes", new int[] { MoleculeItem.getMolecule(moleculeStack).id() });
                    }
                    this.result = result.copy();
                    return result;
                }
            }
        }
    }
    return null;
}
Also used : ItemFood(net.minecraft.item.ItemFood) MoleculeItem(minechem.item.molecule.MoleculeItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 14 with ItemFood

use of net.minecraft.item.ItemFood in project ArsMagica2 by Mithion.

the class TileEntityCalefactor method smeltItem.

public void smeltItem() {
    if (this.canSmelt()) {
        ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.calefactorItemStacks[0]);
        ItemStack smeltStack = var1.copy();
        if (this.calefactorItemStacks[0].getItem() instanceof ItemFood || this.calefactorItemStacks[0].getItem() instanceof ItemBlock || this.calefactorItemStacks[0].getItem() == ItemsCommonProxy.itemOre) {
            if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.DARK, getCookTickPowerCost()))
                if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.NEUTRAL, getCookTickPowerCost()))
                    if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.LIGHT, getCookTickPowerCost()))
                        smeltStack.stackSize++;
        }
        if (this.calefactorItemStacks[0].getItem() instanceof ItemFood) {
            if (smeltStack.stackSize == var1.stackSize && worldObj.rand.nextDouble() < 0.15f) {
                smeltStack.stackSize++;
            }
        }
        boolean doSmelt = true;
        if (doSmelt) {
            if (this.calefactorItemStacks[1] == null) {
                this.calefactorItemStacks[1] = smeltStack.copy();
            } else if (this.calefactorItemStacks[1].isItemEqual(smeltStack)) {
                calefactorItemStacks[1].stackSize += smeltStack.stackSize;
                if (calefactorItemStacks[1].stackSize > calefactorItemStacks[1].getMaxStackSize()) {
                    calefactorItemStacks[1].stackSize = calefactorItemStacks[1].getMaxStackSize();
                }
            }
            if (Math.random() <= 0.25) {
                if (calefactorItemStacks[5] == null) {
                    calefactorItemStacks[5] = new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST);
                } else {
                    calefactorItemStacks[5].stackSize++;
                    if (calefactorItemStacks[5].stackSize > calefactorItemStacks[5].getMaxStackSize()) {
                        calefactorItemStacks[5].stackSize = calefactorItemStacks[5].getMaxStackSize();
                    }
                }
            }
        }
        --this.calefactorItemStacks[0].stackSize;
        if (this.calefactorItemStacks[0].stackSize <= 0) {
            this.calefactorItemStacks[0] = null;
        }
    }
}
Also used : ItemFood(net.minecraft.item.ItemFood) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 15 with ItemFood

use of net.minecraft.item.ItemFood in project BloodMagic by WayofTime.

the class EntityIceDemon method interact.

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
    ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
    if (this.isTamed()) {
        if (itemstack != null) {
            if (itemstack.getItem() instanceof ItemFood) {
                ItemFood itemfood = (ItemFood) itemstack.getItem();
                if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < maxTamedHealth) {
                    if (!par1EntityPlayer.capabilities.isCreativeMode) {
                        --itemstack.stackSize;
                    }
                    this.heal((float) itemfood.func_150905_g(itemstack));
                    if (itemstack.stackSize <= 0) {
                        par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
                    }
                    return true;
                }
            }
        }
        if (this.getOwner() instanceof EntityPlayer && SpellHelper.getUsername(par1EntityPlayer).equalsIgnoreCase(SpellHelper.getUsername((EntityPlayer) this.getOwner())) && !this.isBreedingItem(itemstack)) {
            if (!this.worldObj.isRemote) {
                this.aiSit.setSitting(!this.isSitting());
                this.isJumping = false;
                this.setPathToEntity(null);
                this.setTarget(null);
                this.setAttackTarget(null);
            }
            this.sendSittingMessageToPlayer(par1EntityPlayer, !this.isSitting());
        }
    } else if (itemstack != null && itemstack.getItem().equals(ModItems.weakBloodOrb) && !this.isAngry()) {
        if (!par1EntityPlayer.capabilities.isCreativeMode) {
            --itemstack.stackSize;
        }
        if (itemstack.stackSize <= 0) {
            par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
        }
        if (!this.worldObj.isRemote) {
            if (this.rand.nextInt(1) == 0) {
                this.setTamed(true);
                this.setPathToEntity(null);
                this.setAttackTarget(null);
                this.aiSit.setSitting(true);
                this.setHealth(maxTamedHealth);
                this.func_152115_b(par1EntityPlayer.getUniqueID().toString());
                this.playTameEffect(true);
                this.worldObj.setEntityState(this, (byte) 7);
            } else {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte) 6);
            }
        }
        return true;
    }
    return super.interact(par1EntityPlayer);
}
Also used : ItemFood(net.minecraft.item.ItemFood) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemFood (net.minecraft.item.ItemFood)33 ItemStack (net.minecraft.item.ItemStack)26 EntityPlayer (net.minecraft.entity.player.EntityPlayer)12 Item (net.minecraft.item.Item)7 TileEntity (net.minecraft.tileentity.TileEntity)4 InvWrapper (net.minecraftforge.items.wrapper.InvWrapper)4 BlockPos (net.minecraft.util.math.BlockPos)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 TileEntityColonyBuilding (com.minecolonies.coremod.tileentities.TileEntityColonyBuilding)2 ItemBlock (net.minecraft.item.ItemBlock)2 ItemSoup (net.minecraft.item.ItemSoup)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntityChest (net.minecraft.tileentity.TileEntityChest)2 ItemAmbrosia (biomesoplenty.common.item.ItemAmbrosia)1 ItemBOPBoat (biomesoplenty.common.item.ItemBOPBoat)1 ItemBOPFood (biomesoplenty.common.item.ItemBOPFood)1 ItemBOPRecord (biomesoplenty.common.item.ItemBOPRecord)1 ItemBiomeEssence (biomesoplenty.common.item.ItemBiomeEssence)1 ItemBiomeFinder (biomesoplenty.common.item.ItemBiomeFinder)1 ItemFlowerBasket (biomesoplenty.common.item.ItemFlowerBasket)1