diff --git a/MODSRC/vazkii/botania/client/lib/LibResources.java b/MODSRC/vazkii/botania/client/lib/LibResources.java index 8345c1c64..d13f95dfe 100644 --- a/MODSRC/vazkii/botania/client/lib/LibResources.java +++ b/MODSRC/vazkii/botania/client/lib/LibResources.java @@ -38,8 +38,9 @@ public final class LibResources { public static final String GUI_CREATIVE = "botania.png"; public static final String GUI_TOFF = PREFIX_GUI + "toff.png"; public static final String GUI_BOSS_BAR = PREFIX_GUI + "bossBar.png"; + public static final String GUI_POTIONS = PREFIX_GUI + "potions.png"; public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; - + public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png"; public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png"; diff --git a/MODSRC/vazkii/botania/common/brew/BrewModPotion.java b/MODSRC/vazkii/botania/common/brew/BrewModPotion.java new file mode 100644 index 000000000..bf2de4827 --- /dev/null +++ b/MODSRC/vazkii/botania/common/brew/BrewModPotion.java @@ -0,0 +1,23 @@ +/** + * 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 @ [Nov 2, 2014, 10:37:12 PM (GMT)] + */ +package vazkii.botania.common.brew; + +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public class BrewModPotion extends BrewMod { + + public BrewModPotion(String key, int cost, PotionEffect... effects) { + super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects); + } + +} diff --git a/MODSRC/vazkii/botania/common/brew/ModBrews.java b/MODSRC/vazkii/botania/common/brew/ModBrews.java index 8b0a4a5a9..6cdb5b3d7 100644 --- a/MODSRC/vazkii/botania/common/brew/ModBrews.java +++ b/MODSRC/vazkii/botania/common/brew/ModBrews.java @@ -31,6 +31,8 @@ public class ModBrews { public static Brew nightVision; public static Brew absorption; + public static Brew soulCross; + public static void init() { speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(Potion.moveSpeed.id, 1800, 1)); strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(Potion.damageBoost.id, 1800, 1)); @@ -44,6 +46,8 @@ public class ModBrews { invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 4000, new PotionEffect(Potion.invisibility.id, 9600, 0)); nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0)); absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)); + + soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); } } diff --git a/MODSRC/vazkii/botania/common/brew/ModPotions.java b/MODSRC/vazkii/botania/common/brew/ModPotions.java index 2d6a9e964..7fcda5b81 100644 --- a/MODSRC/vazkii/botania/common/brew/ModPotions.java +++ b/MODSRC/vazkii/botania/common/brew/ModPotions.java @@ -11,10 +11,46 @@ */ package vazkii.botania.common.brew; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +import net.minecraft.potion.Potion; +import vazkii.botania.common.brew.potion.PotionSoulCross; + public class ModPotions { - public static void init() { - - } + public static Potion soulCross; + public static void init() { + if(Potion.potionTypes.length < 256) + extendPotionArray(); + + soulCross = new PotionSoulCross(); + } + + // This is the method that everyone and their mom uses right? + // Source: http://www.minecraftforge.net/wiki/Potion_Tutorial + private static void extendPotionArray() { + Potion[] potionTypes = null; + + for(Field f : Potion.class.getDeclaredFields()) { + f.setAccessible(true); + try { + if(f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { + Field modfield = Field.class.getDeclaredField("modifiers"); + modfield.setAccessible(true); + modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); + + potionTypes = (Potion[]) f.get(null); + Potion[] newPotionTypes = new Potion[256]; + System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); + f.set(null, newPotionTypes); + } + } catch (Exception e) { + System.err.println("Botania done goofed:"); + System.err.println(e); + } + } + } + } diff --git a/MODSRC/vazkii/botania/common/brew/potion/PotionMod.java b/MODSRC/vazkii/botania/common/brew/potion/PotionMod.java new file mode 100644 index 000000000..de00cc5b4 --- /dev/null +++ b/MODSRC/vazkii/botania/common/brew/potion/PotionMod.java @@ -0,0 +1,47 @@ +/** + * 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 @ [Nov 2, 2014, 10:12:45 PM (GMT)] + */ +package vazkii.botania.common.brew.potion; + +import net.minecraft.client.Minecraft; +import net.minecraft.potion.Potion; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.client.lib.LibResources; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PotionMod extends Potion { + + private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); + + public PotionMod(String name, boolean badEffect, int color, int iconIndex) { + super(findFreeID(), badEffect, color); + setPotionName("botania.potion." + name); + setIconIndex(iconIndex % 8 * 8, iconIndex / 8); + } + + static int findFreeID() { + for(int i = 0; i < potionTypes.length; i++) + if(potionTypes[i] == null) + return i; + + return -1; + } + + @Override + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() { + Minecraft.getMinecraft().renderEngine.bindTexture(resource); + + return super.getStatusIconIndex(); + } + +} diff --git a/MODSRC/vazkii/botania/common/brew/potion/PotionSoulCross.java b/MODSRC/vazkii/botania/common/brew/potion/PotionSoulCross.java new file mode 100644 index 000000000..f1e737838 --- /dev/null +++ b/MODSRC/vazkii/botania/common/brew/potion/PotionSoulCross.java @@ -0,0 +1,22 @@ +/** + * 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 @ [Nov 2, 2014, 10:31:48 PM (GMT)] + */ +package vazkii.botania.common.brew.potion; + +import vazkii.botania.common.lib.LibPotionNames; + +public class PotionSoulCross extends PotionMod { + + public PotionSoulCross() { + super(LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); + } + +} diff --git a/MODSRC/vazkii/botania/common/lib/LibBrewNames.java b/MODSRC/vazkii/botania/common/lib/LibBrewNames.java index 927a90cdf..05fdc0e6e 100644 --- a/MODSRC/vazkii/botania/common/lib/LibBrewNames.java +++ b/MODSRC/vazkii/botania/common/lib/LibBrewNames.java @@ -26,4 +26,6 @@ public final class LibBrewNames { public static final String NIGHT_VISION = "nightVision"; public static final String ABSORPTION = "absorption"; + public static final String SOUL_CROSS = "soulCross"; + } diff --git a/MODSRC/vazkii/botania/common/lib/LibPotionNames.java b/MODSRC/vazkii/botania/common/lib/LibPotionNames.java new file mode 100644 index 000000000..a24b978a7 --- /dev/null +++ b/MODSRC/vazkii/botania/common/lib/LibPotionNames.java @@ -0,0 +1,18 @@ +/** + * 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 @ [Nov 2, 2014, 10:33:37 PM (GMT)] + */ +package vazkii.botania.common.lib; + +public final class LibPotionNames { + + public static final String SOUL_CROSS = "soulCross"; + +} diff --git a/resources/assets/botania/lang/en_US.lang b/resources/assets/botania/lang/en_US.lang index 8bdc4848f..b3ac5b023 100644 --- a/resources/assets/botania/lang/en_US.lang +++ b/resources/assets/botania/lang/en_US.lang @@ -787,6 +787,10 @@ botania.brew.waterBreathing=Gills botania.brew.invisibility=Cloaking botania.brew.nightVision=Owlsight botania.brew.absorption=Shielding +botania.brew.soulCross=Crossed Souls + +# POTION NAMES +botania.potion.soulCross=Soul Cross # GUI TEXT botania.gui.lexicon.header=Lexica Botania, %s Edition Table of Contents diff --git a/resources/assets/botania/textures/gui/potions.png b/resources/assets/botania/textures/gui/potions.png new file mode 100644 index 000000000..b922862c2 Binary files /dev/null and b/resources/assets/botania/textures/gui/potions.png differ