diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index 5de6ca976..73b9eaa49 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -32,15 +32,12 @@ public class ModBrews { public static Brew nightVision; public static Brew absorption; + public static Brew allure; public static Brew soulCross; public static Brew featherfeet; public static Brew emptiness; - public static Brew fulfilment; - public static Brew livingReactor; + public static Brew bloodthirst; public static Brew overload; - public static Brew manashock; - public static Brew gravitation; - public static Brew cleansing; public static Brew warpWard; @@ -59,15 +56,12 @@ public class ModBrews { 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)).setNotBloodPendantInfusable(); - /*soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); + overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(Potion.damageBoost.id, 1800, 3), new PotionEffect(Potion.moveSpeed.id, 1800, 2), new PotionEffect(Potion.weakness.id, 1800, 2), new PotionEffect(Potion.hunger.id, 200, 2)); + soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0)); featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0)); emptiness = new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness.id, 7200, 0)); - fulfilment = new BrewModPotion(LibBrewNames.FULFILMENT, 20000, new PotionEffect(ModPotions.fulfilment.id, 7200, 0)); - livingReactor = new BrewModPotion(LibBrewNames.LIVING_REACTOR, 9000, new PotionEffect(ModPotions.livingReactor.id, 200, 0)); - overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(Potion.damageBoost.id, 1800, 3), new PotionEffect(Potion.moveSpeed.id, 1800, 2), new PotionEffect(Potion.weakness.id, 1800, 2), new PotionEffect(Potion.hunger.id, 200, 0)); - manashock = new BrewModPotion(LibBrewNames.MANASHOCK, 15000, new PotionEffect(ModPotions.manashock.id, 200, 0)); - gravitation = new BrewModPotion(LibBrewNames.MANASHOCK, 12000, new PotionEffect(ModPotions.gravitation.id, 1800, 0)); - cleansing = new BrewModPotion(LibBrewNames.CLEANSING, 16000, new PotionEffect(ModPotions.cleansing.id, 1200, 0));*/ + bloodthirst = new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst.id, 7200, 0)); + allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure.id, 4800, 0)); } public static void initTC() { diff --git a/src/main/java/vazkii/botania/common/brew/ModPotions.java b/src/main/java/vazkii/botania/common/brew/ModPotions.java index 9e5c758ee..f0fb5182a 100644 --- a/src/main/java/vazkii/botania/common/brew/ModPotions.java +++ b/src/main/java/vazkii/botania/common/brew/ModPotions.java @@ -11,31 +11,56 @@ */ 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.PotionAllure; +import vazkii.botania.common.brew.potion.PotionBloodthirst; +import vazkii.botania.common.brew.potion.PotionEmptiness; +import vazkii.botania.common.brew.potion.PotionFeatherfeet; +import vazkii.botania.common.brew.potion.PotionSoulCross; public class ModPotions { public static Potion soulCross; public static Potion featherfeet; public static Potion emptiness; - public static Potion fulfilment; - public static Potion livingReactor; - public static Potion manashock; - public static Potion gravitation; - public static Potion cleansing; + public static Potion bloodthrst; + public static Potion allure; public static void init() { - /*if(Potion.potionTypes.length < 256) + if(Potion.potionTypes.length < 256) extendPotionArray(); soulCross = new PotionSoulCross(); featherfeet = new PotionFeatherfeet(); emptiness = new PotionEmptiness(); - fulfilment = new PotionFulfilment(); - livingReactor = new PotionLivingReactor(); - manashock = new PotionManashock(); - gravitation = new PotionGravitation(); - cleansing = new PotionCleansing();*/ + bloodthrst = new PotionBloodthirst(); + allure = new PotionAllure(); + } + + 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); + final Potion[] newPotionTypes = new Potion[256]; + System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); + f.set(null, newPotionTypes); + } + } catch (Exception e) { + System.err.println("Severe error, please report this to the mod author:"); + System.err.println(e); + } + } } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java new file mode 100644 index 000000000..ac168d658 --- /dev/null +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java @@ -0,0 +1,39 @@ +/** + * 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 3, 2014, 12:15:09 AM (GMT)] + */ +package vazkii.botania.common.brew.potion; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import vazkii.botania.common.lib.LibPotionNames; + +public class PotionAllure extends PotionMod { + + public PotionAllure() { + super(LibPotionNames.ALLURE, false, 0x0034E4, 5); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if(e instanceof EntityPlayer && hasEffect(e)) { + EntityFishHook hook = ((EntityPlayer) e).fishEntity; + if(hook != null) + hook.onUpdate(); + } + } + +} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java new file mode 100644 index 000000000..2202292cb --- /dev/null +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.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 3, 2014, 12:13:09 AM (GMT)] + */ +package vazkii.botania.common.brew.potion; + +import java.util.List; + +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.eventhandler.Event.Result; +import vazkii.botania.common.brew.ModPotions; +import vazkii.botania.common.lib.LibPotionNames; + +public class PotionBloodthirst extends PotionMod { + + private static final int RANGE = 64; + + public PotionBloodthirst() { + super(LibPotionNames.BLOODTHIRST, false, 0xC30000, 3); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); + for(EntityPlayer player : players) + if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness)) { + event.setResult(Result.ALLOW); + return; + } + } + } + +} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionCleansing.java b/src/main/java/vazkii/botania/common/brew/potion/PotionCleansing.java deleted file mode 100644 index 8aa91545b..000000000 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionCleansing.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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 3, 2014, 12:17:08 AM (GMT)] - */ -package vazkii.botania.common.brew.potion; - -import vazkii.botania.common.lib.LibPotionNames; - -public class PotionCleansing extends PotionMod { - - public PotionCleansing() { - super(LibPotionNames.CLEANSING, false, 0xFF2B94, 7); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java index 38749285f..447f1d79a 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java @@ -11,12 +11,36 @@ */ package vazkii.botania.common.brew.potion; +import java.util.List; + +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionEmptiness extends PotionMod { + private static final int RANGE = 128; + public PotionEmptiness() { super(LibPotionNames.EMPTINESS, false, 0xE7E7E7, 2); + MinecraftForge.EVENT_BUS.register(this); } + @SubscribeEvent + public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + if(event.getResult() != Result.ALLOW && event.entityLiving instanceof IMob) { + List players = event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.x - RANGE, event.y - RANGE, event.z - RANGE, event.x + RANGE, event.y + RANGE, event.z + RANGE)); + for(EntityPlayer player : players) + if(hasEffect(player)) { + event.setResult(Result.DENY); + return; + } + } + } + } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java index 9b4bad6dc..d3ab257a1 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java @@ -11,12 +11,24 @@ */ package vazkii.botania.common.brew.potion; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionFeatherfeet extends PotionMod { public PotionFeatherfeet() { super(LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) { + EntityLivingBase e = event.entityLiving; + if(hasEffect(e)) + e.fallDistance = 0F; } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionFulfilment.java b/src/main/java/vazkii/botania/common/brew/potion/PotionFulfilment.java deleted file mode 100644 index 794d42cc2..000000000 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionFulfilment.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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 3, 2014, 12:13:09 AM (GMT)] - */ -package vazkii.botania.common.brew.potion; - -import vazkii.botania.common.lib.LibPotionNames; - -public class PotionFulfilment extends PotionMod { - - public PotionFulfilment() { - super(LibPotionNames.FULFILMENT, false, 0xF4C4AE, 3); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionGravitation.java b/src/main/java/vazkii/botania/common/brew/potion/PotionGravitation.java deleted file mode 100644 index bb2f2a49d..000000000 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionGravitation.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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 3, 2014, 12:16:43 AM (GMT)] - */ -package vazkii.botania.common.brew.potion; - -import vazkii.botania.common.lib.LibPotionNames; - -public class PotionGravitation extends PotionMod { - - public PotionGravitation() { - super(LibPotionNames.GRAVITATION, false, 0x6000FF, 6); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionLivingReactor.java b/src/main/java/vazkii/botania/common/brew/potion/PotionLivingReactor.java deleted file mode 100644 index a9cd66dd4..000000000 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionLivingReactor.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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 3, 2014, 12:14:00 AM (GMT)] - */ -package vazkii.botania.common.brew.potion; - -import vazkii.botania.common.lib.LibPotionNames; - -public class PotionLivingReactor extends PotionMod { - - public PotionLivingReactor() { - super(LibPotionNames.LIVING_REACTOR, false, 0x0FB662, 4); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionManashock.java b/src/main/java/vazkii/botania/common/brew/potion/PotionManashock.java deleted file mode 100644 index aa10878ef..000000000 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionManashock.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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 3, 2014, 12:15:09 AM (GMT)] - */ -package vazkii.botania.common.brew.potion; - -import vazkii.botania.common.lib.LibPotionNames; - -public class PotionManashock extends PotionMod { - - public PotionManashock() { - super(LibPotionNames.MANASHOCK, false, 0x0034E4, 5); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java index 83cae540a..f291545a4 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java @@ -12,6 +12,7 @@ package vazkii.botania.common.brew.potion; import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; import vazkii.botania.client.lib.LibResources; @@ -43,5 +44,13 @@ public class PotionMod extends Potion { return super.getStatusIconIndex(); } + + public boolean hasEffect(EntityLivingBase entity) { + return hasEffect(entity, this); + } + + public boolean hasEffect(EntityLivingBase entity, Potion potion) { + return entity.getActivePotionEffect(potion) != null; + } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java index f1e737838..fbbf24b26 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java @@ -11,12 +11,28 @@ */ package vazkii.botania.common.brew.potion; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingDeathEvent; import vazkii.botania.common.lib.LibPotionNames; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PotionSoulCross extends PotionMod { public PotionSoulCross() { super(LibPotionNames.SOUL_CROSS, false, 0x47453d, 0); + MinecraftForge.EVENT_BUS.register(this); } + @SubscribeEvent + public void onEntityKill(LivingDeathEvent event) { + Entity e = event.source.getEntity(); + if(e != null && e instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) e; + if(hasEffect(living)) + living.heal(event.entityLiving.getMaxHealth() / 20); + } + } + } diff --git a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java index 0cdf3df2a..74fe33327 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java @@ -30,12 +30,9 @@ public final class LibBrewNames { public static final String SOUL_CROSS = "soulCross"; public static final String FEATHER_FEET = "featherFeet"; public static final String EMPTINESS = "emptiness"; - public static final String FULFILMENT = "fulfilment"; - public static final String LIVING_REACTOR = "livingReactor"; + public static final String BLOODTHIRST = "bloodthirst"; public static final String OVERLOAD = "overload"; - public static final String MANASHOCK = "manashock"; - public static final String GRAVITATION = "gravitation"; - public static final String CLEANSING = "cleansing"; + public static final String ALLURE = "allure"; public static final String WARP_WARD = "warpWard"; diff --git a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java index 6883be343..a16a8a239 100644 --- a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java @@ -16,10 +16,7 @@ public final class LibPotionNames { public static final String SOUL_CROSS = "soulCross"; public static final String FEATHER_FEET = "featherFeet"; public static final String EMPTINESS = "emptiness"; - public static final String FULFILMENT = "fulfilment"; - public static final String LIVING_REACTOR = "livingReactor"; - public static final String MANASHOCK = "manashock"; - public static final String GRAVITATION = "gravitation"; - public static final String CLEANSING = "cleansing"; + public static final String BLOODTHIRST = "bloodthirst"; + public static final String ALLURE = "allure"; } diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 4c446617d..1681fcb24 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -828,23 +828,17 @@ botania.brew.absorption=Shielding botania.brew.soulCross=Crossed Souls botania.brew.featherFeet=Feather Feet botania.brew.emptiness=Vanity's Emptiness -botania.brew.fulfilment=Vanity's Fulfilment +botania.brew.bloodthirst=Crimson Shade botania.brew.overload=Overload -botania.brew.livingReactor=Living Reactive -botania.brew.manashock=Manashock -botania.brew.gravitation=Twisted Gravity -botania.brew.cleansing=Cleansing +botania.brew.allure=Marine Allure botania.brew.warpWard=Sane Thoughts # POTION NAMES botania.potion.soulCross=Soul Cross botania.potion.featherFeet=Feather Feet botania.potion.emptiness=Emptiness -botania.potion.fulfilment=Fulfilment -botania.potion.livingReactor=Living Reactor -botania.potion.manashock=Manashock -botania.potion.gravitation=Gravitation -botania.potion.cleansing=Cleansing +botania.potion.bloodthirst=Bloodthirst +botania.potion.allure=Allure # GUI TEXT botania.gui.lexicon.header=Lexica Botania, %s Edition Table of Contents diff --git a/src/main/resources/assets/botania/textures/gui/potions.png b/src/main/resources/assets/botania/textures/gui/potions.png index cc5dfc88a..15e80491b 100644 Binary files a/src/main/resources/assets/botania/textures/gui/potions.png and b/src/main/resources/assets/botania/textures/gui/potions.png differ