From 1efbf409e09eb2f124fdda1cf97a41f0048d1805 Mon Sep 17 00:00:00 2001 From: HellFirePvP <01ecs01m> Date: Mon, 7 Dec 2015 20:42:44 +0100 Subject: [PATCH] - Added some custom potion handling --- .../common/potions/PotionCustomTexture.java | 47 +++++++++++++++++++ .../common/potions/PotionMiningLuck.java | 20 ++++++++ .../registration/RegisteredPotions.java | 5 ++ .../assets/gadomancy/lang/en_US.lang | 4 +- 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/main/java/makeo/gadomancy/common/potions/PotionCustomTexture.java create mode 100644 src/main/java/makeo/gadomancy/common/potions/PotionMiningLuck.java diff --git a/src/main/java/makeo/gadomancy/common/potions/PotionCustomTexture.java b/src/main/java/makeo/gadomancy/common/potions/PotionCustomTexture.java new file mode 100644 index 0000000..23489d2 --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/potions/PotionCustomTexture.java @@ -0,0 +1,47 @@ +package makeo.gadomancy.common.potions; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ResourceLocation; + +import java.awt.Color; + +/** + * This class is part of the Gadomancy Mod + * Gadomancy is Open Source and distributed under the + * GNU LESSER GENERAL PUBLIC LICENSE + * for more read the LICENSE file + * + * Created by HellFirePvP @ 07.12.2015 20:31 + */ +public abstract class PotionCustomTexture extends Potion { + + private ResourceLocation texture; + + protected PotionCustomTexture(int id, boolean isBad, int color, ResourceLocation texture) { + super(id, isBad, color); + this.texture = texture; + } + + @Override + public boolean hasStatusIcon() { + return false; + } + + @Override + public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { + Tessellator tes = Tessellator.instance; + mc.renderEngine.bindTexture(texture); + tes.startDrawingQuads(); + Color c = new Color(getLiquidColor()); + tes.setColorRGBA(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()); + tes.addVertexWithUV(x + 6, y + 7, 0, 0, 0); + tes.addVertexWithUV(x + 6, y + 7 + 18, 0, 0, 1); + tes.addVertexWithUV(x + 6 + 18, y + 7 + 18, 0, 1, 1); + tes.addVertexWithUV(x + 6 + 18, y + 7, 0, 1, 0); + tes.draw(); + } + +} diff --git a/src/main/java/makeo/gadomancy/common/potions/PotionMiningLuck.java b/src/main/java/makeo/gadomancy/common/potions/PotionMiningLuck.java new file mode 100644 index 0000000..359d92d --- /dev/null +++ b/src/main/java/makeo/gadomancy/common/potions/PotionMiningLuck.java @@ -0,0 +1,20 @@ +package makeo.gadomancy.common.potions; + +import thaumcraft.api.aspects.Aspect; + +/** + * This class is part of the Gadomancy Mod + * Gadomancy is Open Source and distributed under the + * GNU LESSER GENERAL PUBLIC LICENSE + * for more read the LICENSE file + *
+ * Created by HellFirePvP @ 07.12.2015 20:05 + */ +public class PotionMiningLuck extends PotionCustomTexture { + + public PotionMiningLuck(int id) { + super(id, false, Aspect.MINE.getColor(), Aspect.MINE.getImage()); + setPotionName("potion.miningluck"); + } + +} diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredPotions.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredPotions.java index 844114e..88b6a3e 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredPotions.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredPotions.java @@ -1,5 +1,6 @@ package makeo.gadomancy.common.registration; +import makeo.gadomancy.common.potions.PotionMiningLuck; import makeo.gadomancy.common.utils.Injector; import net.minecraft.potion.Potion; @@ -12,7 +13,11 @@ import net.minecraft.potion.Potion; * Created by makeo @ 31.10.2015 23:09 */ public class RegisteredPotions { + + public static PotionMiningLuck POTION_MINING_LUCK; + public static void init() { + POTION_MINING_LUCK = registerPotion(PotionMiningLuck.class); } private static