diff --git a/MODSRC/vazkii/botania/api/BotaniaAPI.java b/MODSRC/vazkii/botania/api/BotaniaAPI.java index ea481d817..75c2d814c 100644 --- a/MODSRC/vazkii/botania/api/BotaniaAPI.java +++ b/MODSRC/vazkii/botania/api/BotaniaAPI.java @@ -286,7 +286,7 @@ public final class BotaniaAPI { /** * Registers a Brew Recipe (for the Botanical Brewery). * @param brew The brew in to be set in this recipe. - * @inputs The items used in the recipe, no more than 5. + * @inputs The items used in the recipe, no more than 6. */ public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { RecipeBrew recipe = new RecipeBrew(brew, inputs); diff --git a/MODSRC/vazkii/botania/api/recipe/RecipeBrew.java b/MODSRC/vazkii/botania/api/recipe/RecipeBrew.java index c1f03297b..3a5504f1b 100644 --- a/MODSRC/vazkii/botania/api/recipe/RecipeBrew.java +++ b/MODSRC/vazkii/botania/api/recipe/RecipeBrew.java @@ -96,6 +96,10 @@ public class RecipeBrew { return new ArrayList(inputs); } + public Brew getBrew() { + return brew; + } + public int getManaUsage() { return brew.getManaCost(); } diff --git a/MODSRC/vazkii/botania/client/model/ModelBrewery.java b/MODSRC/vazkii/botania/client/model/ModelBrewery.java index a64595bbf..9e6400004 100644 --- a/MODSRC/vazkii/botania/client/model/ModelBrewery.java +++ b/MODSRC/vazkii/botania/client/model/ModelBrewery.java @@ -51,7 +51,7 @@ public class ModelBrewery extends ModelBase { float f = 1F / 16F; float offset = (float) Math.sin(time / 40) * 0.1F + 0.05F; - int plates = 5; + int plates = render.brewery.getSizeInventory() - 1; float deg = (float) time / 16F; float polerot = -deg * 25F; diff --git a/MODSRC/vazkii/botania/common/block/tile/TileBrewery.java b/MODSRC/vazkii/botania/common/block/tile/TileBrewery.java index 6267591f2..d96117a7e 100644 --- a/MODSRC/vazkii/botania/common/block/tile/TileBrewery.java +++ b/MODSRC/vazkii/botania/common/block/tile/TileBrewery.java @@ -11,33 +11,21 @@ */ package vazkii.botania.common.block.tile; +import java.awt.Color; import java.util.List; -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ResourceLocation; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.api.recipe.RecipeBrew; -import vazkii.botania.api.recipe.RecipeRuneAltar; -import vazkii.botania.client.core.handler.ClientTickHandler; -import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibBlockNames; // This is mostly copypasta from TileRuneAltar @@ -47,6 +35,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, public RecipeBrew recipe; int mana = 0; + int manaLastTick = 0; public int signal = 0; public boolean addItem(EntityPlayer player, ItemStack stack) { @@ -87,6 +76,17 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, public void updateEntity() { super.updateEntity(); + if(mana > 0 && recipe == null) { + for(RecipeBrew recipe : BotaniaAPI.brewRecipes) + if(recipe.matches(this)) { + this.recipe = recipe; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2); + } + + if(recipe == null) + mana = 0; + } + // Update every tick. recieveMana(0); @@ -105,20 +105,34 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, recipe = null; worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 | 2); } - - if(recipe != null && mana >= recipe.getManaUsage() && !worldObj.isRemote) { - int mana = recipe.getManaUsage(); - recieveMana(-mana); - if(!worldObj.isRemote) { - ItemStack output = recipe.getOutput(getStackInSlot(0)); - EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); - worldObj.spawnEntityInWorld(outputItem); + + if(recipe != null) { + if(mana != manaLastTick) { + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = (float) color.getRed() / 255F; + float g = (float) color.getGreen() / 255F; + float b = (float) color.getBlue() / 255F; + for(int i = 0; i < 5; i++) { + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, r, g, b, 0.1F + (float) Math.random() * 0.05F, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); + for(int j = 0; j < 2; j++) + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, -(0.04F + (float) Math.random() * 0.02F)); + } } - for(int i = 0; i < getSizeInventory(); i++) - setInventorySlotContents(i, null); + if(mana >= getManaCost() && !worldObj.isRemote) { + int mana = getManaCost(); + recieveMana(-mana); + if(!worldObj.isRemote) { + ItemStack output = recipe.getOutput(getStackInSlot(0)); + EntityItem outputItem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, output); + worldObj.spawnEntityInWorld(outputItem); + } - craftingFanciness(); + for(int i = 0; i < getSizeInventory(); i++) + setInventorySlotContents(i, null); + + craftingFanciness(); + } } } @@ -130,15 +144,27 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, signal = newSignal; worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); } + + manaLastTick = mana; } + public int getManaCost() { + ItemStack stack = getStackInSlot(0); + if(recipe == null || stack == null || !(stack.getItem() instanceof IBrewContainer)) + return 0; + IBrewContainer container = (IBrewContainer) stack.getItem(); + return container.getManaCost(recipe.getBrew(), stack); + } + public void craftingFanciness() { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:runeAltarCraft", 1F, 1F); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:potionCreate", 1F, 1.5F + (float) Math.random() * 0.25F); for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - 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); + Color color = new Color(recipe.getBrew().getColor(getStackInSlot(0))); + float r = (float) color.getRed() / 255F; + float g = (float) color.getGreen() / 255F; + float b = (float) color.getBlue() / 255F; + Botania.proxy.sparkleFX(worldObj, xCoord + 0.5 + Math.random() * 0.4 - 0.2, yCoord + 1, zCoord + 0.5 + Math.random() * 0.4 - 0.2, r, g, b, (float) Math.random() * 2F + 0.5F, 10); + Botania.proxy.wispFX(worldObj, xCoord + 0.7 - Math.random() * 0.4, yCoord + 0.9 - Math.random() * 0.2, zCoord + 0.7 - Math.random() * 0.4, 0.2F, 0.2F, 0.2F, 0.1F + (float) Math.random() * 0.2F, -(0.04F + (float) Math.random() * 0.02F)); } } @@ -158,7 +184,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, @Override public int getSizeInventory() { - return 6; + return 7; } @Override @@ -203,12 +229,12 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory, @Override public boolean isFull() { - return recipe == null ? true : mana >= recipe.getManaUsage(); + return mana >= getManaCost(); } @Override public void recieveMana(int mana) { - this.mana = Math.min(this.mana + mana, recipe == null ? 0 : recipe.getManaUsage()); + this.mana = Math.min(this.mana + mana, getManaCost()); } @Override diff --git a/resources/assets/botania/sounds.json b/resources/assets/botania/sounds.json index f4c508278..458ad5cf1 100644 --- a/resources/assets/botania/sounds.json +++ b/resources/assets/botania/sounds.json @@ -18,6 +18,7 @@ "manaBlaster": { "category": "neutral", "sounds":["manaBlaster"] }, "manaPoolCraft": { "category": "neutral", "sounds":["manaPoolCraft"] }, "orechid": { "category": "neutral", "sounds":["orechid"] }, + "potionCreate": { "category": "neutral", "sounds":["potionCreate"] }, "runeAltarCraft": { "category": "neutral", "sounds":["runeAltarCraft"] }, "runeAltarStart": { "category": "neutral", "sounds":["runeAltarStart"] }, "spreaderFire": { "category": "neutral", "sounds":["spreaderFire"] }, diff --git a/resources/assets/botania/sounds/potionCreate.ogg b/resources/assets/botania/sounds/potionCreate.ogg new file mode 100644 index 000000000..8967d312e Binary files /dev/null and b/resources/assets/botania/sounds/potionCreate.ogg differ