diff --git a/MODSRC/vazkii/botania/api/mana/ICreativeManaProvider.java b/MODSRC/vazkii/botania/api/mana/ICreativeManaProvider.java new file mode 100644 index 000000000..24813a7d0 --- /dev/null +++ b/MODSRC/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [May 25, 2014, 7:34:00 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; + +/** + * Have an item implement this to flag it as an infinite + * mana source for the purposes of the HUD rendered when + * an IManaUserItem implementing item is present. + */ +public interface ICreativeManaProvider { + + public boolean isCreative(ItemStack stack); + +} + diff --git a/MODSRC/vazkii/botania/api/mana/IManaItem.java b/MODSRC/vazkii/botania/api/mana/IManaItem.java index a6dd9de2a..9d2ed0671 100644 --- a/MODSRC/vazkii/botania/api/mana/IManaItem.java +++ b/MODSRC/vazkii/botania/api/mana/IManaItem.java @@ -58,5 +58,10 @@ public interface IManaItem { * Can this item export mana to another item? */ public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack); + + /** + * If this item simply does not export mana in any have, set this to true. + */ + public boolean isNoExport(ItemStack stack); } diff --git a/MODSRC/vazkii/botania/api/mana/IManaUsingItem.java b/MODSRC/vazkii/botania/api/mana/IManaUsingItem.java new file mode 100644 index 000000000..ff914f54b --- /dev/null +++ b/MODSRC/vazkii/botania/api/mana/IManaUsingItem.java @@ -0,0 +1,26 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [May 25, 2014, 7:32:10 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.item.ItemStack; + +/** + * Any item that implements this interface is an item that would use mana + * from the player's inventory. If there's any items in the inventory or + * equipped in either the baubles or armor inventories that implement + * this interface, a mana bar will be rendered. + */ +public interface IManaUsingItem { + + public boolean usesMana(ItemStack stack); + +} diff --git a/MODSRC/vazkii/botania/api/mana/ManaItemHandler.java b/MODSRC/vazkii/botania/api/mana/ManaItemHandler.java index fd1dc42bb..0fae0a0c2 100644 --- a/MODSRC/vazkii/botania/api/mana/ManaItemHandler.java +++ b/MODSRC/vazkii/botania/api/mana/ManaItemHandler.java @@ -34,7 +34,6 @@ public final class ManaItemHandler { IInventory mainInv = player.inventory; IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - new ArrayList(); int invSize = mainInv.getSizeInventory(); int size = invSize; if(baublesInv != null) @@ -80,7 +79,6 @@ public final class ManaItemHandler { IInventory mainInv = player.inventory; IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - new ArrayList(); int invSize = mainInv.getSizeInventory(); int size = invSize; if(baublesInv != null) @@ -124,7 +122,6 @@ public final class ManaItemHandler { IInventory mainInv = player.inventory; IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - new ArrayList(); int invSize = mainInv.getSizeInventory(); int size = invSize; if(baublesInv != null) @@ -175,7 +172,6 @@ public final class ManaItemHandler { IInventory mainInv = player.inventory; IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - new ArrayList(); int invSize = mainInv.getSizeInventory(); int size = invSize; if(baublesInv != null) diff --git a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java index 006e8e259..64381abd0 100644 --- a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java +++ b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java @@ -17,6 +17,9 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; @@ -28,10 +31,14 @@ import org.lwjgl.opengl.GL11; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.mana.ICreativeManaProvider; +import vazkii.botania.api.mana.IManaItem; +import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.item.ModItems; +import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public final class HUDHandler { @@ -58,9 +65,77 @@ public final class HUDHandler { drawLexiconGUI(entry, event.resolution); } } + } else if(event.type == ElementType.EXPERIENCE) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + int totalMana = 0; + int totalMaxMana = 0; + boolean anyRequest = false; + boolean creative = false; + + IInventory mainInv = player.inventory; + IInventory baublesInv = PlayerHandler.getPlayerBaubles(player); + + int invSize = mainInv.getSizeInventory(); + int size = invSize; + if(baublesInv != null) + size += baublesInv.getSizeInventory(); + + for(int i = 0; i < size; i++) { + boolean useBaubles = i >= invSize; + IInventory inv = useBaubles ? baublesInv : mainInv; + ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); + + if(stack != null) { + Item item = stack.getItem(); + if(item instanceof IManaUsingItem) + anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); + + if(item instanceof IManaItem) { + if(!((IManaItem) item).isNoExport(stack)) { + totalMana += ((IManaItem) item).getMana(stack); + totalMaxMana += ((IManaItem) item).getMaxMana(stack); + } + } + + if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) + creative = true; + } + } + + if(anyRequest) + renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); } } + private void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana, int totalMaxMana) { + int width = 182; + int x = res.getScaledWidth() / 2 - width / 2; + int y = res.getScaledHeight() - 29; + + if(!hasCreative) { + if(totalMaxMana == 0) + width = 0; + else width *= ((double) totalMana / (double) totalMaxMana); + } + + if(width == 0) { + if(totalMana > 0) + width = 1; + else return; + } + + Minecraft mc = Minecraft.getMinecraft(); + + Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F)); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) (255 - color.getRed())); + mc.renderEngine.bindTexture(manaBar); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5); + GL11.glDisable(GL11.GL_BLEND); + } + private void drawLexiconGUI(LexiconEntry entry, ScaledResolution res) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); diff --git a/MODSRC/vazkii/botania/common/item/ItemManaMirror.java b/MODSRC/vazkii/botania/common/item/ItemManaMirror.java index 7bffc82df..904832737 100644 --- a/MODSRC/vazkii/botania/common/item/ItemManaMirror.java +++ b/MODSRC/vazkii/botania/common/item/ItemManaMirror.java @@ -233,4 +233,9 @@ public class ItemManaMirror extends ItemMod implements IManaItem { } + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + } diff --git a/MODSRC/vazkii/botania/common/item/ItemManaTablet.java b/MODSRC/vazkii/botania/common/item/ItemManaTablet.java index a954521d6..5e53e12a5 100644 --- a/MODSRC/vazkii/botania/common/item/ItemManaTablet.java +++ b/MODSRC/vazkii/botania/common/item/ItemManaTablet.java @@ -23,12 +23,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import vazkii.botania.api.mana.ICreativeManaProvider; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -public class ItemManaTablet extends ItemMod implements IManaItem { +public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaProvider { IIcon[] icons; @@ -150,4 +151,14 @@ public class ItemManaTablet extends ItemMod implements IManaItem { public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { return true; } + + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + + @Override + public boolean isCreative(ItemStack stack) { + return isStackCreative(stack); + } } diff --git a/MODSRC/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java b/MODSRC/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java index 8cfda7659..1b04ee0e4 100644 --- a/MODSRC/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java +++ b/MODSRC/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java @@ -105,4 +105,9 @@ public class ItemManaRing extends ItemBauble implements IManaItem { return true; } + @Override + public boolean isNoExport(ItemStack stack) { + return false; + } + } diff --git a/MODSRC/vazkii/botania/common/item/equipment/tool/ItemManasteelPick.java b/MODSRC/vazkii/botania/common/item/equipment/tool/ItemManasteelPick.java index c77aba63d..bf3685599 100644 --- a/MODSRC/vazkii/botania/common/item/equipment/tool/ItemManasteelPick.java +++ b/MODSRC/vazkii/botania/common/item/equipment/tool/ItemManasteelPick.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.BotaniaCreativeTab; @@ -28,7 +29,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemManasteelPick extends ItemPickaxe { +public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem { private static final int MANA_PER_DAMAGE = 60; @@ -78,4 +79,9 @@ public class ItemManasteelPick extends ItemPickaxe { return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } + @Override + public boolean usesMana(ItemStack stack) { + return true; + } + } diff --git a/MODSRC/vazkii/botania/common/item/equipment/tool/ItemTerraPick.java b/MODSRC/vazkii/botania/common/item/equipment/tool/ItemTerraPick.java index 669d7c769..5abdaf4e5 100644 --- a/MODSRC/vazkii/botania/common/item/equipment/tool/ItemTerraPick.java +++ b/MODSRC/vazkii/botania/common/item/equipment/tool/ItemTerraPick.java @@ -95,7 +95,6 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem { if(isEnabled(par1ItemStack)) { int level = getLevel(par1ItemStack); - System.out.println(level); if(level == 0) setEnabled(par1ItemStack, false); else if(par3Entity instanceof EntityPlayer && !((EntityPlayer) par3Entity).isSwingInProgress) @@ -222,4 +221,9 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem { return false; } + @Override + public boolean isNoExport(ItemStack stack) { + return true; + } + } diff --git a/build.properties b/build.properties index d08e96f1e..93e8094a9 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ -#Wed, 21 May 2014 13:53:26 +0100 +#Wed, 21 May 2014 21:31:00 +0100 version=beta -build_number=37 +build_number=38 mc_version=1.7.2 mod_name=Botania dir.repo=./ diff --git a/resources/assets/botania/textures/gui/manaHud.png b/resources/assets/botania/textures/gui/manaHud.png index c20c60c8c..b16d2797d 100644 Binary files a/resources/assets/botania/textures/gui/manaHud.png and b/resources/assets/botania/textures/gui/manaHud.png differ diff --git a/web/changelog.txt b/web/changelog.txt index 376b7542a..7d722ecef 100644 --- a/web/changelog.txt +++ b/web/changelog.txt @@ -1,3 +1,7 @@ +beta 37 +*Fixed a crash with the Mana Enchanter with invalid blocks around. +*Fixed the Band of Mana despawning like normal items. +*Fixed the Band of Mana not having a damage bar. beta 36 *Added an extra little bit of info to the Terra Shatterer's entry. *Fixed the Jaded Amaranthus being able to place flowers in running water, basically creating instant farms. diff --git a/web/versions.ini b/web/versions.ini index 0b396eb7d..16f06fc3f 100644 --- a/web/versions.ini +++ b/web/versions.ini @@ -33,4 +33,5 @@ beta-32=1.7.2 beta-33=1.7.2 beta-34=1.7.2 beta-35=1.7.2 -beta-36=1.7.2 \ No newline at end of file +beta-36=1.7.2 +beta-37=1.7.2 \ No newline at end of file