mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Reworked compost to accept custom recipes
This commit is contained in:
parent
93b51eb853
commit
b71af53d13
11 changed files with 173 additions and 68 deletions
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.*;
|
import de.ellpeck.actuallyadditions.api.recipe.*;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
@ -29,7 +30,7 @@ public class ActuallyAdditionsAPI{
|
||||||
|
|
||||||
public static final String MOD_ID = "actuallyadditions";
|
public static final String MOD_ID = "actuallyadditions";
|
||||||
public static final String API_ID = MOD_ID+"api";
|
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
|
* Use this to handle things that aren't based in the API itself
|
||||||
|
@ -44,6 +45,7 @@ public class ActuallyAdditionsAPI{
|
||||||
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<LensConversionRecipe>();
|
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<LensConversionRecipe>();
|
||||||
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
|
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
|
||||||
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
|
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
|
||||||
|
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
|
||||||
|
|
||||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
|
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
|
||||||
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>();
|
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>();
|
||||||
|
@ -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
|
* Adds an item to the list of possible items to be returned when right-clicking a Ball Of Fur
|
||||||
*
|
*
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,10 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
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.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.tile.TileEntityCompost;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
|
@ -57,8 +55,6 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
|
||||||
this.setHardness(0.5F);
|
this.setHardness(0.5F);
|
||||||
this.setResistance(5.0F);
|
this.setResistance(5.0F);
|
||||||
this.setSoundType(SoundType.WOOD);
|
this.setSoundType(SoundType.WOOD);
|
||||||
|
|
||||||
//this.setBlockBoundsForItemRender();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -89,37 +85,60 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stackPlayer, EnumFacing f6, float f7, float f8, float f9){
|
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){
|
if(!world.isRemote){
|
||||||
TileEntityCompost tile = (TileEntityCompost)world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile != null){
|
if(tile instanceof TileEntityCompost){
|
||||||
//Add items to be composted
|
TileEntityCompost compost = (TileEntityCompost)tile;
|
||||||
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))){
|
ItemStack slot = compost.getStackInSlot(0);
|
||||||
if(tile.slots[0] == null){
|
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
|
||||||
tile.slots[0] = new ItemStack(stackPlayer.getItem(), 1, TheMiscItems.MASHED_FOOD.ordinal());
|
if(slot == null || recipeIn != null){
|
||||||
}
|
if(stackPlayer != null){
|
||||||
else{
|
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
|
||||||
tile.slots[0].stackSize++;
|
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
|
||||||
}
|
int maxAdd = Math.min(recipeHand.input.stackSize, stackPlayer.stackSize);
|
||||||
if(!player.capabilities.isCreativeMode){
|
|
||||||
stackPlayer.stackSize--;
|
|
||||||
}
|
|
||||||
tile.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add Fertilizer to player's inventory
|
if(slot == null){
|
||||||
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){
|
ItemStack stackToAdd = stackPlayer.copy();
|
||||||
if(stackPlayer == null){
|
stackToAdd.stackSize = maxAdd;
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.slots[0].copy());
|
compost.setInventorySlotContents(0, stackToAdd);
|
||||||
|
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
stackPlayer.stackSize += tile.slots[0].stackSize;
|
ItemStack stackIn = slot.copy();
|
||||||
}
|
if(stackIn.stackSize < recipeHand.input.stackSize){
|
||||||
tile.slots[0] = null;
|
int sizeAdded = Math.min(maxAdd, recipeHand.input.stackSize-stackIn.stackSize);
|
||||||
tile.markDirty();
|
stackIn.stackSize+=sizeAdded;
|
||||||
}
|
compost.setInventorySlotContents(0, stackIn);
|
||||||
}
|
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(stackPlayer == null){
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy());
|
||||||
|
compost.setInventorySlotContents(0, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,13 +10,15 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
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.tile.TileEntityCompost;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -27,8 +29,25 @@ public class RenderCompost extends TileEntitySpecialRenderer{
|
||||||
public void renderTileEntityAt(@Nonnull TileEntity te, double x, double y, double z, float partialTicks, int destroyStage){
|
public void renderTileEntityAt(@Nonnull TileEntity te, double x, double y, double z, float partialTicks, int destroyStage){
|
||||||
if(te instanceof TileEntityCompost){
|
if(te instanceof TileEntityCompost){
|
||||||
TileEntityCompost compost = (TileEntityCompost)te;
|
TileEntityCompost compost = (TileEntityCompost)te;
|
||||||
if(compost.getStackInSlot(0) != null){
|
ItemStack slot = compost.getStackInSlot(0);
|
||||||
float i = compost.getAmount()/TileEntityCompost.AMOUNT;
|
|
||||||
|
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.pushMatrix();
|
||||||
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
|
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
|
||||||
//Hehe
|
//Hehe
|
||||||
|
@ -36,10 +55,11 @@ public class RenderCompost extends TileEntitySpecialRenderer{
|
||||||
GlStateManager.translate(0F, 1F, 0F);
|
GlStateManager.translate(0F, 1F, 0F);
|
||||||
}
|
}
|
||||||
GlStateManager.scale(1.5F, i, 1.5F);
|
GlStateManager.scale(1.5F, i, 1.5F);
|
||||||
AssetUtil.renderBlockInWorld(Blocks.DIRT, compost.getStackInSlot(0).getItem() == InitItems.itemFertilizer ? 1 : 0);
|
AssetUtil.renderBlockInWorld(display, 0);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("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).setStack(new ItemStack(InitItems.itemFertilizer)).addTextReplacement("<num>", 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("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("<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());
|
||||||
|
|
||||||
|
|
|
@ -105,12 +105,12 @@ public class CrusherCrafting{
|
||||||
recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe();
|
recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6));
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget"));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget"));
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("denseore", 8));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("denseore", 8));
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("gem", 1));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("gem", 1));
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("ingot", 1));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ingot", 1));
|
||||||
CrusherRecipeRegistry.searchCases.add(new CrusherRecipeRegistry.SearchCase("ore", 2));
|
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2));
|
||||||
|
|
||||||
CrusherRecipeRegistry.registerFinally();
|
CrusherRecipeRegistry.registerFinally();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
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 de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class InitCrafting{
|
public class InitCrafting{
|
||||||
|
|
||||||
|
@ -22,6 +27,8 @@ public class InitCrafting{
|
||||||
MiscCrafting.init();
|
MiscCrafting.init();
|
||||||
FoodCrafting.init();
|
FoodCrafting.init();
|
||||||
ToolCrafting.init();
|
ToolCrafting.init();
|
||||||
|
|
||||||
|
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 10, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer, 10), Blocks.DIRT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.gen.cave;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.WorldData;
|
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.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.playerdata.PersistentServerData;
|
import de.ellpeck.actuallyadditions.mod.util.playerdata.PersistentServerData;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -36,6 +37,8 @@ public class CaveWorldType extends WorldType{
|
||||||
super("actaddcaveworld");
|
super("actaddcaveworld");
|
||||||
|
|
||||||
Util.registerEvent(this);
|
Util.registerEvent(this);
|
||||||
|
|
||||||
|
ModUtil.LOGGER.info("Cave World config enabled! Registering cave world type...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCave(World world){
|
public static boolean isCave(World world){
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class CrusherRecipeRegistry{
|
public class CrusherRecipeRegistry{
|
||||||
|
|
||||||
public static final ArrayList<SearchCase> searchCases = new ArrayList<SearchCase>();
|
public static final ArrayList<SearchCase> SEARCH_CASES = new ArrayList<SearchCase>();
|
||||||
|
|
||||||
public static void registerFinally(){
|
public static void registerFinally(){
|
||||||
ArrayList<String> oresNoResult = new ArrayList<String>();
|
ArrayList<String> oresNoResult = new ArrayList<String>();
|
||||||
|
@ -32,7 +32,7 @@ public class CrusherRecipeRegistry{
|
||||||
|
|
||||||
for(String ore : OreDictionary.getOreNames()){
|
for(String ore : OreDictionary.getOreNames()){
|
||||||
if(!hasException(ore)){
|
if(!hasException(ore)){
|
||||||
for(SearchCase theCase : searchCases){
|
for(SearchCase theCase : SEARCH_CASES){
|
||||||
if(ore.length() > theCase.theCase.length()){
|
if(ore.length() > theCase.theCase.length()){
|
||||||
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
|
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
|
||||||
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
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.ItemFertilizer;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemMisc;
|
import de.ellpeck.actuallyadditions.mod.items.ItemMisc;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
|
@ -22,7 +23,6 @@ import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileEntityCompost extends TileEntityInventoryBase{
|
public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
|
|
||||||
public static final int AMOUNT = 10;
|
|
||||||
public int conversionTime;
|
public int conversionTime;
|
||||||
|
|
||||||
public TileEntityCompost(){
|
public TileEntityCompost(){
|
||||||
|
@ -35,10 +35,6 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
compound.setInteger("ConversionTime", this.conversionTime);
|
compound.setInteger("ConversionTime", this.conversionTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAmount(){
|
|
||||||
return this.getStackInSlot(0) != null ? this.getStackInSlot(0).stackSize : 0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSyncSlots(){
|
public boolean shouldSyncSlots(){
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,27 +51,31 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!this.worldObj.isRemote){
|
if(!this.worldObj.isRemote){
|
||||||
boolean theFlag = this.conversionTime > 0;
|
boolean theFlag = this.conversionTime > 0;
|
||||||
if(this.slots[0] != null && !(this.slots[0].getItem() instanceof ItemFertilizer) && this.slots[0].stackSize >= 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++;
|
this.conversionTime++;
|
||||||
if(this.conversionTime >= 2000){
|
if(this.conversionTime >= 3000){
|
||||||
this.slots[0] = new ItemStack(InitItems.itemFertilizer, AMOUNT);
|
this.slots[0] = recipe.output.copy();
|
||||||
|
this.conversionTime = 0;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
this.conversionTime = 0;
|
this.conversionTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theFlag != this.conversionTime > 0){
|
if(theFlag != this.conversionTime > 0){
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit(){
|
|
||||||
return AMOUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, @Nonnull ItemStack stack){
|
public boolean isItemValidForSlot(int i, @Nonnull ItemStack stack){
|
||||||
return stack.getItem() instanceof ItemMisc && stack.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal();
|
return getRecipeForInput(stack) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,6 +91,17 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, @Nonnull ItemStack stack, @Nonnull EnumFacing side){
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -713,7 +713,7 @@ booklet.actuallyadditions.chapter.feeder.name=Feeder
|
||||||
booklet.actuallyadditions.chapter.feeder.text.1=The <item>Feeder<r> 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 <imp>automatically feed the animals<r> and if there is enough animals near it, it will <imp>shut off on its own<r> to prevent lag or animal overflow. <n><n><i>Greenpeace approves
|
booklet.actuallyadditions.chapter.feeder.text.1=The <item>Feeder<r> 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 <imp>automatically feed the animals<r> and if there is enough animals near it, it will <imp>shut off on its own<r> to prevent lag or animal overflow. <n><n><i>Greenpeace approves
|
||||||
|
|
||||||
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>Fertilizier<r> from <item>Mashed Food<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Mashed Food<r> and then putting <num> of those inside of a <item>Compost<r> 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 <item>Compost<r> is used to make <item>Fertilizier<r> from <item>Mashed Food<r>. <item>Fertilizer<r> acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting <item>Mashed Food<r> and then putting 10 of those inside of a <item>Compost<r> and waiting for a bit. When the mashed food 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>Mashed Food<r> can be crafted from <imp>any type of food or plantable item<r>.
|
booklet.actuallyadditions.chapter.compost.text.3=<item>Mashed Food<r> can be crafted from <imp>any type of food or plantable item<r>.
|
||||||
|
|
||||||
booklet.actuallyadditions.chapter.crate.name=Storage Crates
|
booklet.actuallyadditions.chapter.crate.name=Storage Crates
|
||||||
|
|
Loading…
Reference in a new issue