diff --git a/src/main/java/vazkii/botania/common/block/BlockAltar.java b/src/main/java/vazkii/botania/common/block/BlockAltar.java index 9bc359aaa..d523e9566 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltar.java @@ -115,7 +115,9 @@ public class BlockAltar extends BlockModContainer implements ILexiconable { break; } } - } else { + } else if(tile.isEmpty() && stack == null) + tile.trySetLastRecipe(par5EntityPlayer); + else { if(stack != null && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, false))) { if(!tile.hasWater) { if(stack.getItem() == ModItems.waterRod) diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java index 4363d509f..940ef1cf0 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java @@ -71,7 +71,7 @@ public class BlockRuneAltar extends BlockModContainer implements IWandable, IWan @Override public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4); - + ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); if(par5EntityPlayer.isSneaking()) { if(altar.manaToGet == 0) @@ -86,11 +86,10 @@ public class BlockRuneAltar extends BlockModContainer implements IWandable, IWan break; } } - } else { - ItemStack stack = par5EntityPlayer.getCurrentEquippedItem(); - if(stack != null) + } else if(altar.isEmpty() && stack == null) + altar.trySetLastRecipe(par5EntityPlayer); + else if(stack != null) return altar.addItem(par5EntityPlayer, stack); - } return false; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index 361d8812c..0353ae804 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -11,12 +11,16 @@ package vazkii.botania.common.block.tile; import java.awt.Color; +import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -28,6 +32,7 @@ import vazkii.botania.api.item.IPetalApothecary; import vazkii.botania.api.recipe.IFlowerComponent; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.common.Botania; +import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.lib.LibBlockNames; public class TileAltar extends TileSimpleInventory implements ISidedInventory, IPetalApothecary { @@ -42,7 +47,10 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I public boolean hasLava = false; public boolean isMossy = false; - + + List lastRecipe = null; + int recipeKeepTicks = 0; + public boolean collideEntityItem(EntityItem item) { ItemStack stack = item.getEntityItem(); if(stack == null || item.isDead) @@ -100,6 +108,8 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I } else if(stack.getItem() != null && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) { for(RecipePetals recipe : BotaniaAPI.petalRecipes) { if(recipe.matches(this)) { + saveLastRecipe(); + for(int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); @@ -117,6 +127,7 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I setWater(false); worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); didChange = true; + break; } } @@ -124,6 +135,60 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I return didChange; } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if(stack == null) + break; + lastRecipe.add(stack); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + tryToSetLastRecipe(player, this, lastRecipe); + if(!isEmpty()) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } + + public static void tryToSetLastRecipe(EntityPlayer player, IInventory inv, List lastRecipe) { + if(lastRecipe == null || lastRecipe.isEmpty() || player.worldObj.isRemote) + return; + + int index = 0; + boolean didAny = false; + for(ItemStack stack : lastRecipe) { + if(stack == null) + continue; + + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack pstack = player.inventory.getStackInSlot(i); + if(pstack != null && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack)) { + pstack.stackSize--; + if(pstack.stackSize == 0) + player.inventory.setInventorySlotContents(i, null); + + ItemStack stackToPut = pstack.copy(); + stackToPut.stackSize = 1; + inv.setInventorySlotContents(index, stackToPut); + didAny = true; + index++; + break; + } + } + } + + if(didAny) { + if(inv instanceof TileAltar) + player.worldObj.playSoundAtEntity(player, "game.neutral.swim.splash", 0.1F, 1F); + if(player instanceof EntityPlayerMP) { + EntityPlayerMP mp = (EntityPlayerMP) player; + mp.inventoryContainer.detectAndSendChanges(); + } + } + } public void craftingFanciness() { worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:altarCraft", 1F, 1F); @@ -134,6 +199,14 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); } } + + public boolean isEmpty() { + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + return false; + + return true; + } @Override public void updateEntity() { @@ -169,6 +242,10 @@ public class TileAltar extends TileSimpleInventory implements ISidedInventory, I if(Math.random() > 0.9) worldObj.spawnParticle("lava", xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0); } + + if(recipeKeepTicks > 0) + --recipeKeepTicks; + else lastRecipe = null; } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index 1148423e8..791b984ae 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.block.tile; +import java.util.ArrayList; import java.util.List; import net.minecraft.client.Minecraft; @@ -42,6 +43,9 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor int cooldown = 0; public int signal = 0; + List lastRecipe = null; + int recipeKeepTicks = 0; + public boolean addItem(EntityPlayer player, ItemStack stack) { if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon || manaToGet != 0) return false; @@ -112,6 +116,10 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor signal = newSignal; worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); } + + if(recipeKeepTicks > 0) + --recipeKeepTicks; + else lastRecipe = null; } public void updateRecipe() { @@ -131,10 +139,28 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); } } + + public void saveLastRecipe() { + lastRecipe = new ArrayList(); + for(int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if(stack == null) + break; + lastRecipe.add(stack); + } + recipeKeepTicks = 400; + } + + public void trySetLastRecipe(EntityPlayer player) { + TileAltar.tryToSetLastRecipe(player, this, lastRecipe); + if(!isEmpty()) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, xCoord, yCoord, zCoord); + } public boolean hasValidRecipe() { for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) - if(recipe.matches(this)) return true; + if(recipe.matches(this)) + return true; return false; } @@ -170,6 +196,7 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor cooldown = 60; } + saveLastRecipe(); for(int i = 0; i < getSizeInventory(); i++) setInventorySlotContents(i, null); @@ -196,6 +223,14 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, red, green, blue, (float) Math.random(), 10); } } + + public boolean isEmpty() { + for(int i = 0; i < getSizeInventory(); i++) + if(getStackInSlot(i) != null) + return false; + + return true; + } @Override public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) { diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index c06017205..bb8658c67 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -283,7 +283,7 @@ public final class LexiconData { new PageText("6"), new PageCraftingRecipe("7", ModCraftingRecipes.recipeFertilizerPowder), new PageCraftingRecipe("8", ModCraftingRecipes.recipeFerilizerDye), new PageText("10"), new PageCraftingRecipe("11", ModCraftingRecipes.recipesPetalsDouble), new PageCraftingRecipe("9", ModCraftingRecipes.recipesPetalBlocks)).setIcon(new ItemStack(ModBlocks.flower, 1, 6)); apothecary = new BLexiconEntry(LibLexicon.BASICS_APOTHECARY, categoryBasics); - apothecary.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_APOTHECARY), new PageText("2"), new PageText("3"), new PageText("4"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); + apothecary.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_APOTHECARY), new PageText("2"), new PageText("3"), new PageText("4"), new PageText("6"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesApothecary)); lexicon = new BLexiconEntry(LibLexicon.BASICS_LEXICON, categoryBasics); lexicon.setPriority().setLexiconPages(new PageText("0"), new PageText("3"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), new PageText("2")); @@ -297,7 +297,7 @@ public final class LexiconData { LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1); runicAltar = new BLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); - runicAltar.setPriority().setLexiconPages(new PageText("21"), new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), new PageText("3"), new PageText("20"), new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), + runicAltar.setPriority().setLexiconPages(new PageText("21"), new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), new PageText("3"), new PageText("20"), new PageText("21"), new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), new PageRuneRecipe("7", ModRuneRecipes.recipeFireRune), new PageRuneRecipe("8", ModRuneRecipes.recipeSpringRune), new PageRuneRecipe("9", ModRuneRecipes.recipeSummerRune), new PageRuneRecipe("10", ModRuneRecipes.recipeAutumnRune), new PageRuneRecipe("11", ModRuneRecipes.recipesWinterRune), new PageRuneRecipe("12", ModRuneRecipes.recipeManaRune), new PageRuneRecipe("13", ModRuneRecipes.recipeLustRune), new PageRuneRecipe("14", ModRuneRecipes.recipeGluttonyRune), new PageRuneRecipe("15", ModRuneRecipes.recipeGreedRune), new PageRuneRecipe("16", ModRuneRecipes.recipeSlothRune), new PageRuneRecipe("17", ModRuneRecipes.recipeWrathRune), new PageRuneRecipe("18", ModRuneRecipes.recipeEnvyRune), new PageRuneRecipe("19", ModRuneRecipes.recipePrideRune)); diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 613769714..b85435527 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -1415,6 +1415,7 @@ botania.page.apothecary1=The &1Petal Apothecary&0. botania.page.apothecary2=This block, when placed in the world and given some water (by use of a &1Water Bucket&0), will accept any &1Mystical Petals&0 thrown at it, releasing their energies.
Once one has set the correct petals in, throwing some &1Seeds&0 in will finalize the proccess.
Tossing in the full bucket will also fill the recipient with water. botania.page.apothecary3=Quite a few plants can be made using this method, for more information, read on the &4Functional Flora&0 and &4Generation Flora&0 sections of this Lexicon.
Shift-right clicking the &1Petal Apothecary&0 with an empty hand will remove the last item thrown in. botania.page.apothecary4=Instead of &1Water&0, one can place &1Lava&0 in this block, if that is done, it'll serve as a brazier and incinerator, destroying any items that come in contact.
Lastly, tossing in &1Vines&0 also gives the block an overgrown visual. +botania.page.apothecary6=A simple tip for those who want to squeeze the biggest efficiency out of every block is as follows, up to twenty seconds after crafting a flower in this block, right clicking it with an empty hand will pull the items from the inventory required for the recipe and put them into it for quick mass crafting. This only works if it has water. botania.page.apothecary5=Crafting the &1Petal Apothecary&0. # -- PURE DAISY @@ -1440,6 +1441,7 @@ botania.page.runeAltar1=Proceed by linking a &1Mana Spreader&0 to the altar, and botania.page.runeAltar2=Crafting the &1Runic Altar&0. botania.page.runeAltar3=A total of 16 &1Runes&0 exist.
The most basic and elementary runes are named after the &4Four Elements&0. The intermediate runes are named after the &4Four Seasons&0, and the most advanced runes are named after the &4Seven Deadly Sins&0. A separate &1Rune of Mana&0 also exists. botania.page.runeAltar20=Sneaking and right-clicking the &1Runic Altar&0 with an empty hand while it's not accepting mana will remove the last item put into it.
Last but not least, attaching a &1Comparator&0 to it will emit signal strength &41&0 if the altar is accepting &4Mana&0 and signal strength &42&0 if it's ready to craft the rune. +botania.page.runeAltar21=Similarly to the &1Petal Apothecary&0, right clicking this block with an empty hand after a recipe is complete will place back the items used for the last recipe for faster mass crafting. botania.page.runeAltar4=The &1Rune of Water&0. botania.page.runeAltar5=The &1Rune of Earth&0. botania.page.runeAltar6=The &1Rune of Air&0.