From b71af53d13834d31e175b5fdb4f93c9c1faf6cbb Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 20 May 2016 17:55:33 +0200 Subject: [PATCH] Reworked compost to accept custom recipes --- .../api/ActuallyAdditionsAPI.java | 17 ++++- .../api/recipe/CompostRecipe.java | 30 ++++++++ .../mod/blocks/BlockCompost.java | 75 ++++++++++++------- .../mod/blocks/render/RenderCompost.java | 44 ++++++++--- .../mod/booklet/InitBooklet.java | 2 +- .../mod/crafting/CrusherCrafting.java | 12 +-- .../mod/crafting/InitCrafting.java | 7 ++ .../mod/gen/cave/CaveWorldType.java | 3 + .../mod/recipe/CrusherRecipeRegistry.java | 4 +- .../mod/tile/TileEntityCompost.java | 45 ++++++----- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 11 files changed, 173 insertions(+), 68 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 47b6a4f47..d69dc8068 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.LensConversion; import de.ellpeck.actuallyadditions.api.recipe.*; +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -29,7 +30,7 @@ public class ActuallyAdditionsAPI{ public static final String MOD_ID = "actuallyadditions"; public static final String API_ID = MOD_ID+"api"; - public static final String API_VERSION = "14"; + public static final String API_VERSION = "15"; /** * Use this to handle things that aren't based in the API itself @@ -44,6 +45,7 @@ public class ActuallyAdditionsAPI{ public static final List RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList(); public static final Map RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap(); public static final List COFFEE_MACHINE_INGREDIENTS = new ArrayList(); + public static final List COMPOST_RECIPES = new ArrayList(); public static final List BOOKLET_ENTRIES = new ArrayList(); public static final List BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList(); @@ -134,6 +136,19 @@ public class ActuallyAdditionsAPI{ } } + /** + * Adds a new conversion recipe to the compost. + * StackSize is regarded on both input and output and they can be different. + * + * @param input The itemstack to be input into the compost + * @param inputDisplay The block to display when there is input in the compost + * @param output The itemstack to be output from the compost once conversion finishes + * @param outputDisplay The block to display when there is output in the compost + */ + public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){ + COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay)); + } + /** * Adds an item to the list of possible items to be returned when right-clicking a Ball Of Fur * diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java new file mode 100644 index 000000000..e98a877b4 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java @@ -0,0 +1,30 @@ +/* + * This file ("CompostRecipe.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-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.api.recipe; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +public class CompostRecipe{ + + public ItemStack input; + public ItemStack output; + public Block inputDisplay; + public Block outputDisplay; + + public CompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){ + this.input = input; + this.output = output; + this.inputDisplay = inputDisplay; + this.outputDisplay = outputDisplay; + } + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java index 3314dd49a..2077f04b7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java @@ -10,10 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer; -import de.ellpeck.actuallyadditions.mod.items.ItemMisc; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -57,8 +55,6 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{ this.setHardness(0.5F); this.setResistance(5.0F); this.setSoundType(SoundType.WOOD); - - //this.setBlockBoundsForItemRender(); } @Nonnull @@ -89,36 +85,59 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stackPlayer, EnumFacing f6, float f7, float f8, float f9){ if(!world.isRemote){ - TileEntityCompost tile = (TileEntityCompost)world.getTileEntity(pos); - if(tile != null){ - //Add items to be composted - if(stackPlayer != null && stackPlayer.getItem() instanceof ItemMisc && stackPlayer.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal() && (tile.slots[0] == null || (!(tile.slots[0].getItem() instanceof ItemFertilizer) && tile.slots[0].stackSize < TileEntityCompost.AMOUNT))){ - if(tile.slots[0] == null){ - tile.slots[0] = new ItemStack(stackPlayer.getItem(), 1, TheMiscItems.MASHED_FOOD.ordinal()); - } - else{ - tile.slots[0].stackSize++; - } - if(!player.capabilities.isCreativeMode){ - stackPlayer.stackSize--; - } - tile.markDirty(); - } + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof TileEntityCompost){ + TileEntityCompost compost = (TileEntityCompost)tile; + ItemStack slot = compost.getStackInSlot(0); + CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot); + if(slot == null || recipeIn != null){ + if(stackPlayer != null){ + CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer); + if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){ + int maxAdd = Math.min(recipeHand.input.stackSize, stackPlayer.stackSize); - //Add Fertilizer to player's inventory - else if(tile.slots[0] != null && (stackPlayer == null || (stackPlayer.getItem() instanceof ItemFertilizer && stackPlayer.stackSize <= stackPlayer.getMaxStackSize()-tile.slots[0].stackSize)) && tile.slots[0].getItem() instanceof ItemFertilizer){ + if(slot == null){ + ItemStack stackToAdd = stackPlayer.copy(); + stackToAdd.stackSize = maxAdd; + compost.setInventorySlotContents(0, stackToAdd); + player.inventory.decrStackSize(player.inventory.currentItem, maxAdd); + return true; + } + else{ + ItemStack stackIn = slot.copy(); + if(stackIn.stackSize < recipeHand.input.stackSize){ + int sizeAdded = Math.min(maxAdd, recipeHand.input.stackSize-stackIn.stackSize); + stackIn.stackSize+=sizeAdded; + compost.setInventorySlotContents(0, stackIn); + player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded); + return true; + } + } + } + } + } + else{ if(stackPlayer == null){ - player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.slots[0].copy()); + player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy()); + compost.setInventorySlotContents(0, null); + return true; } - else{ - stackPlayer.stackSize += tile.slots[0].stackSize; + else if(stackPlayer.isItemEqual(slot)){ + int addedStackSize = Math.min(slot.stackSize, stackPlayer.getMaxStackSize()-stackPlayer.stackSize); + ItemStack stackToAdd = stackPlayer.copy(); + stackToAdd.stackSize += addedStackSize; + player.inventory.setInventorySlotContents(player.inventory.currentItem, stackToAdd); + compost.decrStackSize(0, addedStackSize); + return true; + } - tile.slots[0] = null; - tile.markDirty(); } } } - return true; + else{ + return true; + } + return false; } @Nonnull diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderCompost.java index ebf7228d3..ade2f73fb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderCompost.java @@ -10,13 +10,15 @@ package de.ellpeck.actuallyadditions.mod.blocks.render; -import de.ellpeck.actuallyadditions.mod.items.InitItems; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import javax.annotation.Nonnull; @@ -27,17 +29,35 @@ public class RenderCompost extends TileEntitySpecialRenderer{ public void renderTileEntityAt(@Nonnull TileEntity te, double x, double y, double z, float partialTicks, int destroyStage){ if(te instanceof TileEntityCompost){ TileEntityCompost compost = (TileEntityCompost)te; - if(compost.getStackInSlot(0) != null){ - float i = compost.getAmount()/TileEntityCompost.AMOUNT; - GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F); - //Hehe - if("ShadowfactsDev".equals(Minecraft.getMinecraft().thePlayer.getName())){ - GlStateManager.translate(0F, 1F, 0F); + ItemStack slot = compost.getStackInSlot(0); + + if(slot != null){ + Block display = null; + int maxAmount = 0; + for(CompostRecipe aRecipe : ActuallyAdditionsAPI.COMPOST_RECIPES){ + if(slot.isItemEqual(aRecipe.input)){ + display = aRecipe.inputDisplay; + maxAmount = aRecipe.input.stackSize; + break; + } + else if(slot.isItemEqual(aRecipe.output)){ + display = aRecipe.outputDisplay; + maxAmount = aRecipe.output.stackSize; + break; + } + } + if(display != null){ + float i = (float)slot.stackSize/(float)maxAmount; + GlStateManager.pushMatrix(); + GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F); + //Hehe + if("ShadowfactsDev".equals(Minecraft.getMinecraft().thePlayer.getName())){ + GlStateManager.translate(0F, 1F, 0F); + } + GlStateManager.scale(1.5F, i, 1.5F); + AssetUtil.renderBlockInWorld(display, 0); + GlStateManager.popMatrix(); } - GlStateManager.scale(1.5F, i, 1.5F); - AssetUtil.renderBlockInWorld(Blocks.DIRT, compost.getStackInSlot(0).getItem() == InitItems.itemFertilizer ? 1 : 0); - GlStateManager.popMatrix(); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 3eabe4441..3c9cb3180 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -99,7 +99,7 @@ public class InitBooklet{ 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("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).setStack(new ItemStack(InitItems.itemFertilizer)).addTextReplacement("", TileEntityCompost.AMOUNT), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageCrafting(3, ItemCrafting.recipesMashedFood)); + new BookletChapter("compost", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemFertilizer)), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageCrafting(3, ItemCrafting.recipesMashedFood)); new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, ItemCrafting.recipeCrateKeeper), new PageCrafting(3, ItemCrafting.recipeChestToCrateUpgrade)); new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockRangedCollector), new PageTextOnly(1).addTextReplacement("", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java index fa9b7351f..2a916d46a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java @@ -105,12 +105,12 @@ public class CrusherCrafting{ recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe(); } - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6)); - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget")); - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("denseore", 8)); - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("gem", 1)); - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("ingot", 1)); - CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("ore", 2)); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6)); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget")); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("denseore", 8)); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("gem", 1)); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ingot", 1)); + CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2)); CrusherRecipeRegistry.registerFinally(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java index 7c6a1d7d3..5f11ad479 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java @@ -10,7 +10,12 @@ package de.ellpeck.actuallyadditions.mod.crafting; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import de.ellpeck.actuallyadditions.mod.items.InitItems; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.ModUtil; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; public class InitCrafting{ @@ -22,6 +27,8 @@ public class InitCrafting{ MiscCrafting.init(); FoodCrafting.init(); ToolCrafting.init(); + + ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 10, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer, 10), Blocks.DIRT); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/cave/CaveWorldType.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/cave/CaveWorldType.java index 7b7076025..44d4ff139 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/cave/CaveWorldType.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/cave/CaveWorldType.java @@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.gen.cave; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.misc.WorldData; +import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.playerdata.PersistentServerData; import net.minecraft.entity.player.EntityPlayerMP; @@ -36,6 +37,8 @@ public class CaveWorldType extends WorldType{ super("actaddcaveworld"); Util.registerEvent(this); + + ModUtil.LOGGER.info("Cave World config enabled! Registering cave world type..."); } public static boolean isCave(World world){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java index 28c768aa2..25fc80555 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java @@ -24,7 +24,7 @@ import java.util.List; public class CrusherRecipeRegistry{ - public static final ArrayList searchCases = new ArrayList(); + public static final ArrayList SEARCH_CASES = new ArrayList(); public static void registerFinally(){ ArrayList oresNoResult = new ArrayList(); @@ -32,7 +32,7 @@ public class CrusherRecipeRegistry{ for(String ore : OreDictionary.getOreNames()){ if(!hasException(ore)){ - for(SearchCase theCase : searchCases){ + for(SearchCase theCase : SEARCH_CASES){ if(ore.length() > theCase.theCase.length()){ if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){ String output = theCase.resultPreString+ore.substring(theCase.theCase.length()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java index f4bba2821..ea713fdf5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java @@ -10,7 +10,8 @@ package de.ellpeck.actuallyadditions.mod.tile; -import de.ellpeck.actuallyadditions.mod.items.InitItems; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer; import de.ellpeck.actuallyadditions.mod.items.ItemMisc; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; @@ -22,7 +23,6 @@ import javax.annotation.Nonnull; public class TileEntityCompost extends TileEntityInventoryBase{ - public static final int AMOUNT = 10; public int conversionTime; public TileEntityCompost(){ @@ -35,10 +35,6 @@ public class TileEntityCompost extends TileEntityInventoryBase{ compound.setInteger("ConversionTime", this.conversionTime); } - public float getAmount(){ - return this.getStackInSlot(0) != null ? this.getStackInSlot(0).stackSize : 0F; - } - @Override public boolean shouldSyncSlots(){ return true; @@ -55,27 +51,31 @@ public class TileEntityCompost extends TileEntityInventoryBase{ super.updateEntity(); if(!this.worldObj.isRemote){ boolean theFlag = this.conversionTime > 0; - if(this.slots[0] != null && !(this.slots[0].getItem() instanceof ItemFertilizer) && this.slots[0].stackSize >= AMOUNT){ - this.conversionTime++; - if(this.conversionTime >= 2000){ - this.slots[0] = new ItemStack(InitItems.itemFertilizer, AMOUNT); + + if(this.slots[0] != null){ + CompostRecipe recipe = getRecipeForInput(this.slots[0]); + if(recipe != null && this.slots[0].isItemEqual(recipe.input) && this.slots[0].stackSize >= recipe.input.stackSize){ + this.conversionTime++; + if(this.conversionTime >= 3000){ + this.slots[0] = recipe.output.copy(); + this.conversionTime = 0; + this.markDirty(); + } + } + else{ this.conversionTime = 0; } } + if(theFlag != this.conversionTime > 0){ this.markDirty(); } } } - @Override - public int getInventoryStackLimit(){ - return AMOUNT; - } - @Override public boolean isItemValidForSlot(int i, @Nonnull ItemStack stack){ - return stack.getItem() instanceof ItemMisc && stack.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal(); + return getRecipeForInput(stack) != null; } @Override @@ -91,6 +91,17 @@ public class TileEntityCompost extends TileEntityInventoryBase{ @Override public boolean canExtractItem(int slot, @Nonnull ItemStack stack, @Nonnull EnumFacing side){ - return stack.getItem() instanceof ItemFertilizer; + return getRecipeForInput(stack) == null; + } + + public static CompostRecipe getRecipeForInput(ItemStack input){ + if(input != null){ + for(CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES){ + if(input.isItemEqual(recipe.input)){ + return recipe; + } + } + } + return null; } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 49d002769..eb04e975a 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -713,7 +713,7 @@ booklet.actuallyadditions.chapter.feeder.name=Feeder booklet.actuallyadditions.chapter.feeder.text.1=The Feeder is a good alternative to a manual animal farm. Place it in the middle of an animal pen and supply it with some wheat, seeds or carrots, depending on the animal you want to feed, and just wait. It will automatically feed the animals and if there is enough animals near it, it will shut off on its own to prevent lag or animal overflow. Greenpeace approves booklet.actuallyadditions.chapter.compost.name=Compost and Fertilizer -booklet.actuallyadditions.chapter.compost.text.1=The Compost is used to make Fertilizier from Mashed Food. Fertilizer acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting Mashed Food and then putting of those inside of a Compost and waiting for a bit. When the mashed food is composted, just take it out by right-clicking again. +booklet.actuallyadditions.chapter.compost.text.1=The Compost is used to make Fertilizier from Mashed Food. Fertilizer acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting Mashed Food and then putting 10 of those inside of a Compost and waiting for a bit. When the mashed food is composted, just take it out by right-clicking again. This, however, also works for some other items, which will be explained when needed. booklet.actuallyadditions.chapter.compost.text.3=Mashed Food can be crafted from any type of food or plantable item. booklet.actuallyadditions.chapter.crate.name=Storage Crates