Made Bio-mash recipes nicer and also dependent on the saturation

Closes #593
This commit is contained in:
Ellpeck 2017-01-30 18:33:18 +01:00
parent 0f95f45d3a
commit 2d4c7db2aa
6 changed files with 100 additions and 31 deletions

View file

@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting; import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting;
import de.ellpeck.actuallyadditions.mod.data.WorldData; import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities; import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.CommonEvents; import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
@ -133,7 +132,6 @@ public class ActuallyAdditions{
InitVillager.init(); InitVillager.init();
ItemCoffee.initIngredients(); ItemCoffee.initIngredients();
CrusherCrafting.init(); CrusherCrafting.init();
ItemCrafting.initMashedFoodRecipes();
HairyBallHandler.init(); HairyBallHandler.init();
TreasureChestHandler.init(); TreasureChestHandler.init();
LensRecipeHandler.init(); LensRecipeHandler.init();

View file

@ -206,7 +206,7 @@ public final class InitBooklet{
new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass)); new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass));
new BookletChapter("fishingNet", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText()); new BookletChapter("fishingNet", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText());
new BookletChapter("feeder", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFeeder), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText()); new BookletChapter("feeder", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFeeder), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText());
new BookletChapter("compost", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemFertilizer)), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageCrafting(3, ItemCrafting.RECIPES_MASHED_FOOD)); new BookletChapter("compost", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemFertilizer)), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageTextOnly(3).addItemToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal())));
new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, BlockCrafting.recipeCrateMedium).setNoText(), new PageCrafting(3, BlockCrafting.recipeCrateLarge).setNoText(), new PageCrafting(4, ItemCrafting.recipeCrateKeeper), new PageCrafting(5, ItemCrafting.recipeChestToCrateUpgrade), new PageCrafting(6, ItemCrafting.recipeSmallToMediumCrateUpgrade), new PageCrafting(7, ItemCrafting.recipeMediumToLargeCrateUpgrade)); new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, BlockCrafting.recipeCrateMedium).setNoText(), new PageCrafting(3, BlockCrafting.recipeCrateLarge).setNoText(), new PageCrafting(4, ItemCrafting.recipeCrateKeeper), new PageCrafting(5, ItemCrafting.recipeChestToCrateUpgrade), new PageCrafting(6, ItemCrafting.recipeSmallToMediumCrateUpgrade), new PageCrafting(7, ItemCrafting.recipeMediumToLargeCrateUpgrade));
new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockRangedCollector), new PageTextOnly(1).addTextReplacement("<range>", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText()); new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockRangedCollector), new PageTextOnly(1).addTextReplacement("<range>", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText());

View file

@ -51,6 +51,9 @@ public final class InitCrafting{
GameRegistry.addRecipe(new RecipePotionRingCharging()); GameRegistry.addRecipe(new RecipePotionRingCharging());
RecipeSorter.register(ModUtil.MOD_ID+":recipePotionRingCharging", RecipePotionRingCharging.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); RecipeSorter.register(ModUtil.MOD_ID+":recipePotionRingCharging", RecipePotionRingCharging.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
GameRegistry.addRecipe(new RecipeBioMash());
RecipeSorter.register(ModUtil.MOD_ID+":recipeBioMash", RecipeBioMash.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
} }
} }

View file

@ -14,23 +14,18 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.*; import de.ellpeck.actuallyadditions.mod.items.metalists.*;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.IGrowable;
import net.minecraft.enchantment.EnchantmentData; import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Enchantments; import net.minecraft.init.Enchantments;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes; import net.minecraft.init.PotionTypes;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.PotionUtils; import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
@ -40,7 +35,6 @@ import java.util.ArrayList;
public final class ItemCrafting{ public final class ItemCrafting{
public static final ArrayList<IRecipe> RECIPES_MASHED_FOOD = new ArrayList<IRecipe>();
public static final ArrayList<IRecipe> RECIPES_POTION_RINGS = new ArrayList<IRecipe>(); public static final ArrayList<IRecipe> RECIPES_POTION_RINGS = new ArrayList<IRecipe>();
public static final ArrayList<IRecipe> RECIPES_DRILL_COLORING = new ArrayList<IRecipe>(); public static final ArrayList<IRecipe> RECIPES_DRILL_COLORING = new ArrayList<IRecipe>();
public static IRecipe recipePhantomConnector; public static IRecipe recipePhantomConnector;
@ -579,25 +573,4 @@ public final class ItemCrafting{
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPotionRingAdvanced, 1, meta), new ItemStack(InitItems.itemPotionRing, 1, meta), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal())); GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPotionRingAdvanced, 1, meta), new ItemStack(InitItems.itemPotionRing, 1, meta), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()));
RECIPES_POTION_RINGS.add(RecipeUtil.lastIRecipe()); RECIPES_POTION_RINGS.add(RecipeUtil.lastIRecipe());
} }
public static void initMashedFoodRecipes(){
for(Item item : Item.REGISTRY){
if(item instanceof ItemFood || item instanceof IPlantable || item instanceof IGrowable){
if(!isBlacklisted(item)){
ItemStack ingredient = new ItemStack(item, 1, Util.WILDCARD);
GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.MASHED_FOOD.ordinal()), ingredient, ingredient, ingredient, ingredient, new ItemStack(InitItems.itemKnife, 1, Util.WILDCARD));
RECIPES_MASHED_FOOD.add(RecipeUtil.lastIRecipe());
}
}
}
}
private static boolean isBlacklisted(Item item){
for(String except : ConfigStringListValues.MASHED_FOOD_CRAFTING_EXCEPTIONS.getValue()){
if(item.getRegistryName().toString().equals(except)){
return true;
}
}
return false;
}
} }

View file

@ -0,0 +1,95 @@
/*
* This file ("RecipeBioMash.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://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemKnife;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
public class RecipeBioMash implements IRecipe{
@Override
public boolean matches(InventoryCrafting inv, World world){
boolean foundFood = false;
boolean hasKnife = false;
for(int i = 0; i < inv.getSizeInventory(); i++){
ItemStack stack = inv.getStackInSlot(i);
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof ItemKnife){
if(hasKnife){
return false;
}
else{
hasKnife = true;
}
}
else if(stack.getItem() instanceof ItemFood){
foundFood = true;
}
else{
return false;
}
}
}
return foundFood && hasKnife;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv){
int amount = 0;
for(int i = 0; i < inv.getSizeInventory(); i++){
ItemStack stack = inv.getStackInSlot(i);
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof ItemFood){
ItemFood food = (ItemFood)stack.getItem();
float heal = food.getHealAmount(stack);
float sat = food.getSaturationModifier(stack);
amount += MathHelper.ceil(heal*sat);
}
}
}
if(amount > 0 && amount <= 64){
return new ItemStack(InitItems.itemMisc, amount, TheMiscItems.MASHED_FOOD.ordinal());
}
else{
return StackUtil.getNull();
}
}
@Override
public int getRecipeSize(){
return 2;
}
@Override
public ItemStack getRecipeOutput(){
return StackUtil.getNull();
}
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv){
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}
}

View file

@ -844,7 +844,7 @@ booklet.actuallyadditions.chapter.feeder.text.1=The <item>Feeder<r> is a good al
booklet.actuallyadditions.chapter.compost.name=Compost and Fertilizer booklet.actuallyadditions.chapter.compost.name=Compost and Fertilizer
booklet.actuallyadditions.chapter.compost.text.1=The <item>Compost<r> is used to make <item>Fertilizer<r> from <item>Bio-Mash<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Bio-Mash<r> and then putting those inside of a <item>Compost<r> and waiting for a bit. When the mash is composted, just take it out by right-clicking again. <n><n>This, however, also works for some other items, which will be explained when needed. booklet.actuallyadditions.chapter.compost.text.1=The <item>Compost<r> is used to make <item>Fertilizer<r> from <item>Bio-Mash<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Bio-Mash<r> and then putting those inside of a <item>Compost<r> and waiting for a bit. When the mash is composted, just take it out by right-clicking again. <n><n>This, however, also works for some other items, which will be explained when needed.
booklet.actuallyadditions.chapter.compost.text.3=<item>Bio-Mash<r> can be crafted from <imp>any type of food or plantable item<r>. booklet.actuallyadditions.chapter.compost.text.3=<item>Bio-Mash<r> can be crafted from <imp>any type of food item<r> by putting any number of it togeter in a crafting grid with a <item>Knife<r>. The resulting amount of <item>Bio-Mash<r> will <imp>vary depending on<r> the food's <imp>saturation<r> and <imp>healing<r> levels.
booklet.actuallyadditions.chapter.crate.name=Storage Crates booklet.actuallyadditions.chapter.crate.name=Storage Crates
booklet.actuallyadditions.chapter.crate.text.1=<item>Storage Crates<r> are big. <imp>Really big<r>. They hold tons of items, more than 4 chests worth of them. <n>Not only that, but they can be <imp>upgraded in size<r>! View the following pages to get information on that and some other items regarding crates! booklet.actuallyadditions.chapter.crate.text.1=<item>Storage Crates<r> are big. <imp>Really big<r>. They hold tons of items, more than 4 chests worth of them. <n>Not only that, but they can be <imp>upgraded in size<r>! View the following pages to get information on that and some other items regarding crates!