Search in sources :

Example 26 with ItemFood

use of net.minecraft.item.ItemFood in project GregTech by GregTechCE.

the class MachineRecipeLoader method registerOrganicRecyclingRecipes.

private static void registerOrganicRecyclingRecipes() {
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(800).EUt(3).input("treeSapling", 1).fluidInputs(Materials.Water.getFluid(100)).fluidOutputs(Materials.Biomass.getFluid(100)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.POTATO)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.CARROT)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.CACTUS)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.REEDS)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.BROWN_MUSHROOM)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Blocks.RED_MUSHROOM)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.BREWING_RECIPES.recipeBuilder().duration(160).EUt(3).inputs(new ItemStack(Items.BEETROOT)).fluidInputs(Materials.Water.getFluid(20)).fluidOutputs(Materials.Biomass.getFluid(20)).buildAndRegister();
    RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder().duration(144).EUt(5).inputs(new ItemStack(Items.NETHER_WART)).fluidOutputs(Materials.Methane.getFluid(18)).buildAndRegister();
    RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder().duration(144).EUt(5).inputs(new ItemStack(Blocks.BROWN_MUSHROOM)).fluidOutputs(Materials.Methane.getFluid(18)).buildAndRegister();
    RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder().duration(144).EUt(5).inputs(new ItemStack(Blocks.RED_MUSHROOM)).fluidOutputs(Materials.Methane.getFluid(18)).buildAndRegister();
    if (ConfigHolder.addFoodMethaneRecipes) {
        for (Item item : ForgeRegistries.ITEMS.getValuesCollection()) {
            if (item instanceof ItemFood) {
                ItemFood itemFood = (ItemFood) item;
                Collection<ItemStack> subItems = ModHandler.getAllSubItems(new ItemStack(item, 1, GTValues.W));
                for (ItemStack itemStack : subItems) {
                    int healAmount = itemFood.getHealAmount(itemStack);
                    float saturationModifier = itemFood.getSaturationModifier(itemStack);
                    if (healAmount > 0) {
                        FluidStack outputStack = Materials.Methane.getFluid(Math.round(9 * healAmount * (1.0f + saturationModifier)));
                        RecipeMaps.CENTRIFUGE_RECIPES.recipeBuilder().duration(144).EUt(5).inputs(itemStack).fluidOutputs(outputStack).buildAndRegister();
                    }
                }
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) MetaItem(gregtech.api.items.metaitem.MetaItem) ItemFood(net.minecraft.item.ItemFood) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack)

Example 27 with ItemFood

use of net.minecraft.item.ItemFood in project Almura by AlmuraDev.

the class FoodLevelChangeApply method apply0.

@Override
public void apply0(final EntityPlayer entity, final ItemApplyContext context) {
    final ItemStack usedStack = context.item();
    if (usedStack.getItem() instanceof ItemFood) {
        final ItemFood food = (ItemFood) usedStack.getItem();
        final int currentFoodLevel = ((FoodStatsAccessor) entity.getFoodStats()).accessor$getFoodLevel();
        ((FoodStatsAccessor) entity.getFoodStats()).accessor$setFoodLevel(Math.min(currentFoodLevel + food.getHealAmount(usedStack), 20));
    }
}
Also used : FoodStatsAccessor(com.almuradev.almura.asm.mixin.accessors.util.FoodStatsAccessor) ItemFood(net.minecraft.item.ItemFood) ItemStack(net.minecraft.item.ItemStack)

Example 28 with ItemFood

use of net.minecraft.item.ItemFood in project Almura by AlmuraDev.

the class MixinEntityAnimal method isCustomBreedingItem.

private boolean isCustomBreedingItem(ItemStack stack) {
    final String itemName = stack.getTranslationKey();
    // System.out.println("Breed Item: " + itemName);
    final Entity animal = this;
    if (animal instanceof EntityCow) {
        switch(itemName.toUpperCase()) {
            case "ITEM.ALMURA.FOOD.FOOD.CORN":
            case "ITEM.ALMURA.FOOD.FOOD.SOYBEAN":
            case "ITEM.ALMURA.NORMAL.CROP.ALFALFA_ITEM":
            case "ITEM.WHEAT":
                return true;
            default:
                return false;
        }
    }
    if (animal instanceof EntityPig) {
        switch(itemName.toUpperCase()) {
            case "ITEM.ALMURA.FOOD.FOOD.CORN":
            case "ITEM.ALMURA.FOOD.FOOD.SOYBEAN":
            case "ITEM.CARROTS":
                return true;
            default:
                return false;
        }
    }
    if (animal instanceof EntitySheep) {
        switch(itemName.toUpperCase()) {
            case "ITEM.ALMURA.FOOD.FOOD.CORN":
            case "ITEM.ALMURA.FOOD.FOOD.SOYBEAN":
            case "ITEM.WHEAT":
                return true;
            default:
                return false;
        }
    }
    if (animal instanceof EntityChicken) {
        switch(itemName.toUpperCase()) {
            case "ITEM.ALMURA.FOOD.FOOD.CORN":
            case "ITEM.ALMURA.FOOD.FOOD.SOYBEAN":
            case "ITEM.SEEDS":
            case "ITEM.SEEDS_MELON":
            case "ITEM.BEETROOT_SEEDS":
            case "ITEM.SEEDS_PUMPKIN":
                return true;
            default:
                return false;
        }
    }
    if (animal instanceof EntityOcelot) {
        switch(itemName.toUpperCase()) {
            case "ITEM.FISH":
                return true;
            default:
                return false;
        }
    }
    if (animal instanceof EntityWolf) {
        return stack.getItem() instanceof ItemFood && ((ItemFood) stack.getItem()).isWolfsFavoriteMeat();
    }
    if (animal instanceof EntityRabbit) {
        return this.isRabbitBreedingItem(stack.getItem());
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) ItemFood(net.minecraft.item.ItemFood) EntityChicken(net.minecraft.entity.passive.EntityChicken) EntityCow(net.minecraft.entity.passive.EntityCow) EntityPig(net.minecraft.entity.passive.EntityPig) EntityRabbit(net.minecraft.entity.passive.EntityRabbit) EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityOcelot(net.minecraft.entity.passive.EntityOcelot) EntityWolf(net.minecraft.entity.passive.EntityWolf)

Example 29 with ItemFood

use of net.minecraft.item.ItemFood in project harvestcraft by MatrexsVigil.

the class ItemRegistry method registerItemVanillaFood.

private static Item registerItemVanillaFood(String registryName, int amount, float saturation, boolean isWolfsFavoriteMeat) {
    final Item item = new ItemFood(amount, saturation, isWolfsFavoriteMeat);
    allFood.add(item);
    return registerItem(item, registryName);
}
Also used : Item(net.minecraft.item.Item) ItemFood(net.minecraft.item.ItemFood)

Example 30 with ItemFood

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

the class EntityMinorDemonGrunt 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 (this.isTameable() && 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