mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Right clicking a Petal Apothecary or Runic Altar with an empty hand after a recipe is completed places the components of that recipe from your inventory into the block again for another crafting.
This commit is contained in:
1 parent
62107c26ec
commit
f92eb3df3b
6 files changed
+125
-10
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ItemStack> 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<ItemStack> 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
|
||||
|
||||
@@ -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<ItemStack> 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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in new issue
Block a user