From a0d251fafd6f963f914c81cc4ebff0127a16dd32 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Tue, 3 May 2016 12:38:52 -0500 Subject: [PATCH] Update forge and close #245 --- build.properties | 2 +- .../botania/common/brew/potion/PotionMod.java | 47 +++++++++++++++---- .../vazkii/botania/common/lib/LibMisc.java | 2 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/build.properties b/build.properties index c1aa7139e..045eecac4 100644 --- a/build.properties +++ b/build.properties @@ -4,6 +4,6 @@ version=r1.8 dir_output=../Build Output/Botania/ dir_repo=./ mc_version=1.9 -forge_version=12.16.0.1865-1.9 +forge_version=12.16.0.1882-1.9 build_number=303 mod_name=Botania 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 a54969417..0eef0873e 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionMod.java @@ -11,8 +11,13 @@ package vazkii.botania.common.brew.potion; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @@ -23,20 +28,13 @@ import vazkii.botania.common.lib.LibMisc; public class PotionMod extends Potion { private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS); + private final int iconIndex; public PotionMod(String name, boolean badEffect, int color, int iconIndex) { super(badEffect, color); GameRegistry.register(this, new ResourceLocation(LibMisc.MOD_ID, name)); setPotionName("botania.potion." + name); - setIconIndex(iconIndex % 8, iconIndex / 8); - } - - @Override - @SideOnly(Side.CLIENT) - public int getStatusIconIndex() { - Minecraft.getMinecraft().renderEngine.bindTexture(resource); - - return super.getStatusIconIndex(); + this.iconIndex = iconIndex; } public boolean hasEffect(EntityLivingBase entity) { @@ -47,4 +45,35 @@ public class PotionMod extends Potion { return entity.getActivePotionEffect(potion) != null; } + @Override + @SideOnly(Side.CLIENT) + public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { + render(x + 6, y + 7, 1); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) { + render(x + 3, y + 3, alpha); + } + + @SideOnly(Side.CLIENT) + private void render(int x, int y, float alpha) { + Minecraft.getMinecraft().renderEngine.bindTexture(resource); + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buf = tessellator.getBuffer(); + buf.begin(7, DefaultVertexFormats.POSITION_TEX); + GlStateManager.color(1, 1, 1, alpha); + + int textureX = iconIndex % 8 * 18; + int textureY = 198 + iconIndex / 8 * 18; + + buf.pos(x, y + 18, 0).tex(textureX * 0.00390625, (textureY + 18) * 0.00390625).endVertex(); + buf.pos(x + 18, y + 18, 0).tex((textureX + 18) * 0.00390625, (textureY + 18) * 0.00390625).endVertex(); + buf.pos(x + 18, y, 0).tex((textureX + 18) * 0.00390625, textureY * 0.00390625).endVertex(); + buf.pos(x, y, 0).tex(textureX * 0.00390625, textureY * 0.00390625).endVertex(); + + tessellator.draw(); + } + } diff --git a/src/main/java/vazkii/botania/common/lib/LibMisc.java b/src/main/java/vazkii/botania/common/lib/LibMisc.java index 25dc59f0d..832a0b601 100644 --- a/src/main/java/vazkii/botania/common/lib/LibMisc.java +++ b/src/main/java/vazkii/botania/common/lib/LibMisc.java @@ -17,7 +17,7 @@ public final class LibMisc { public static final String MOD_NAME = MOD_ID; public static final String BUILD = "GRADLE:BUILD"; public static final String VERSION = "GRADLE:VERSION-" + BUILD; - public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft"; + public static final String DEPENDENCIES = "required-after:Forge@[12.16.0.1874,];required-after:Baubles;after:Thaumcraft"; public static final String MC_VERSIONS = "[1.9]"; // Network Contants