diff --git a/MODSRC/vazkii/botania/api/boss/IBotaniaBoss.java b/MODSRC/vazkii/botania/api/boss/IBotaniaBoss.java new file mode 100644 index 000000000..4839b0871 --- /dev/null +++ b/MODSRC/vazkii/botania/api/boss/IBotaniaBoss.java @@ -0,0 +1,63 @@ +/** + * 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 @ [Oct 29, 2014, 6:09:48 PM (GMT)] + */ +package vazkii.botania.api.boss; + +import java.awt.Rectangle; + +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * An extension of IBossDisplayData. This counts as a botania boss and as a normal + * minecraft boss since it has IBossDisplayData. Instead of using the typical + * BossStatus.setBossStatus(entity, true) to set the health bar in the render use + * BotaniaAPI.internalMethodHandler.setBossStatus(entity);

+ * Alternatively, you can check if botania is loaded and use the vanilla one + * if that's not the case. + */ +public interface IBotaniaBoss extends IBossDisplayData { + + /** + * The ResourceLocation to bind for this boss's boss bar. + * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get + * the one used by botania bosses. + */ + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture(); + + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar texture. This is for the background, not the bar that shows + * the HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect(); + + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar HP texture. This is for the foreground that shows how much + * HP the boss has. The width of the rectangle will be multiplied by the + * faction of the boss's current HP by max HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect(); + + /** + * A callback for when this boss's boss bar renders, you can do aditional rendering + * here if needed. + */ + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(); +} diff --git a/MODSRC/vazkii/botania/api/boss/IBotaniaBossWithShader.java b/MODSRC/vazkii/botania/api/boss/IBotaniaBossWithShader.java new file mode 100644 index 000000000..1bffebb78 --- /dev/null +++ b/MODSRC/vazkii/botania/api/boss/IBotaniaBossWithShader.java @@ -0,0 +1,43 @@ +/** + * 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 @ [Oct 29, 2014, 6:13:21 PM (GMT)] + */ +package vazkii.botania.api.boss; + +import vazkii.botania.api.internal.ShaderCallback; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A Botania boss whose HP bar makes use of shaders. Shaders + * used through this have a few uniforms available: + *
  • int time - The amount of total ticks elapsed.
  • + *
  • int startX - The U coordinate passed in for the render of this bar's texture.
  • + *
  • int startY - The V coordinate passed in for the render of this bar's texture.
  • + */ +public interface IBotaniaBossWithShader extends IBotaniaBoss { + + /** + * The Shader Program to use for this boss bar. Return 0 case + * you don't want a shader to be used. You can use separate shaders + * for the background and foreground. + * @param background True if rendering the background of the boss bar, + * false if rendering the bar itself that shows the HP. + */ + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background); + + /** + * A callback for the shader, used to pass in uniforms. Return null for no callback. + */ + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader); + +} diff --git a/MODSRC/vazkii/botania/api/internal/DummyMethodHandler.java b/MODSRC/vazkii/botania/api/internal/DummyMethodHandler.java index 22e9da466..1207e54b5 100644 --- a/MODSRC/vazkii/botania/api/internal/DummyMethodHandler.java +++ b/MODSRC/vazkii/botania/api/internal/DummyMethodHandler.java @@ -21,7 +21,9 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; @@ -144,4 +146,14 @@ public class DummyMethodHandler implements IInternalMethodHandler { return 0; } + @Override + public ResourceLocation getDefaultBossBarTexture() { + return null; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + // NO-OP + } + } diff --git a/MODSRC/vazkii/botania/api/internal/IInternalMethodHandler.java b/MODSRC/vazkii/botania/api/internal/IInternalMethodHandler.java index f75f208a4..8c1e29725 100644 --- a/MODSRC/vazkii/botania/api/internal/IInternalMethodHandler.java +++ b/MODSRC/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -20,7 +20,9 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.lexicon.LexiconPage; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; @@ -82,6 +84,12 @@ public interface IInternalMethodHandler { @SideOnly(Side.CLIENT) public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); + @SideOnly(Side.CLIENT) + public ResourceLocation getDefaultBossBarTexture(); + + @SideOnly(Side.CLIENT) + public void setBossStatus(IBotaniaBoss status); + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); } diff --git a/MODSRC/vazkii/botania/api/internal/ShaderCallback.java b/MODSRC/vazkii/botania/api/internal/ShaderCallback.java new file mode 100644 index 000000000..095b673c3 --- /dev/null +++ b/MODSRC/vazkii/botania/api/internal/ShaderCallback.java @@ -0,0 +1,21 @@ +/** + * 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 @ [Oct 29, 2014, 6:31:35 PM (GMT)] + */ +package vazkii.botania.api.internal; + +/** + * A Callback for when a shader is called. Used to define shader uniforms. + */ +public abstract class ShaderCallback { + + public abstract void call(int shader); + +} diff --git a/MODSRC/vazkii/botania/client/core/handler/BossBarHandler.java b/MODSRC/vazkii/botania/client/core/handler/BossBarHandler.java new file mode 100644 index 000000000..10aaa9b97 --- /dev/null +++ b/MODSRC/vazkii/botania/client/core/handler/BossBarHandler.java @@ -0,0 +1,117 @@ +/** + * 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 @ [Oct 29, 2014, 6:46:10 PM (GMT)] + */ +package vazkii.botania.client.core.handler; + +import java.awt.Rectangle; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.ARBShaderObjects; +import org.lwjgl.opengl.GL11; + +import vazkii.botania.api.boss.IBotaniaBoss; +import vazkii.botania.api.boss.IBotaniaBossWithShader; +import vazkii.botania.api.internal.ShaderCallback; +import vazkii.botania.client.core.helper.RenderHelper; +import vazkii.botania.client.core.helper.ShaderHelper; +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.core.helper.MathHelper; + +public final class BossBarHandler { + + public static final ResourceLocation defaultBossBar = new ResourceLocation(LibResources.GUI_BOSS_BAR); + static IBotaniaBoss currentBoss; + + private static final BarCallback barUniformCallback = new BarCallback(); + + public static void setCurrentBoss(IBotaniaBoss status) { + currentBoss = status; + } + + public static void render(ScaledResolution res) { + if(currentBoss == null) + return; + + Minecraft mc = Minecraft.getMinecraft(); + Rectangle bgRect = currentBoss.getBossBarTextureRect(); + Rectangle fgRect = currentBoss.getBossBarHPTextureRect(); + String name = currentBoss.func_145748_c_().getFormattedText(); + int c = res.getScaledWidth() / 2; + int x = c - bgRect.width / 2; + int y = 20; + int xf = x + (bgRect.width - fgRect.width) / 2; + int yf = y + (bgRect.height - fgRect.height) / 2; + int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth())); + int tx = c - mc.fontRenderer.getStringWidth(name) / 2; + + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + currentBoss.bossBarRenderCallback(); + mc.renderEngine.bindTexture(currentBoss.getBossBarTexture()); + drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true); + drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false); + mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C); + GL11.glDisable(GL11.GL_BLEND); + + Entity e = (Entity) currentBoss; + EntityPlayer p = mc.thePlayer; + if(e.isDead || !e.worldObj.loadedEntityList.contains(e) || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32) + currentBoss = null; + } + + public static void drawBar(int x, int y, int u, int v, int w, int h, boolean bg) { + boolean useShader = currentBoss instanceof IBotaniaBossWithShader; + if(useShader) { + IBotaniaBossWithShader shader = (IBotaniaBossWithShader) currentBoss; + int program = shader.getBossBarShaderProgram(bg); + ShaderCallback callback = program == 0 ? null : shader.getBossBarShaderCallback(bg, program); + barUniformCallback.set(u, v, callback); + + ShaderHelper.useShader(program, barUniformCallback); + } + + RenderHelper.drawTexturedModalRect(x, y, 0, u, v, w, h); + + if(useShader) + ShaderHelper.releaseShader(); + } + + static class BarCallback extends ShaderCallback { + int x, y; + ShaderCallback callback; + + @Override + public void call(int shader) { + int startXUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startX"); + int startYUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "startY"); + + + ARBShaderObjects.glUniform1iARB(startXUniform, x); + ARBShaderObjects.glUniform1iARB(startYUniform, y); + + if(callback != null) + callback.call(shader); + } + + void set(int x, int y, ShaderCallback callback) { + this.x = x; + this.y = y; + this.callback = callback; + } + } + +} diff --git a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java index 91c00597f..28e4b3b84 100644 --- a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java +++ b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java @@ -129,6 +129,8 @@ public final class HUDHandler { if(anyRequest) renderManaInvBar(event.resolution, creative, totalMana, totalMaxMana); + profiler.endStartSection("bossBar"); + BossBarHandler.render(event.resolution); profiler.endSection(); profiler.endSection(); } diff --git a/MODSRC/vazkii/botania/client/core/helper/ShaderHelper.java b/MODSRC/vazkii/botania/client/core/helper/ShaderHelper.java index 02b39a73a..fa3a31351 100644 --- a/MODSRC/vazkii/botania/client/core/helper/ShaderHelper.java +++ b/MODSRC/vazkii/botania/client/core/helper/ShaderHelper.java @@ -23,6 +23,7 @@ import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.ARBVertexShader; import org.lwjgl.opengl.GL11; +import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; @@ -38,6 +39,7 @@ public final class ShaderHelper { public static int manaPool = 0; public static int doppleganger = 0; public static int halo = 0; + public static int dopplegangerBar = 0; public static void initShaders() { if(!useShaders()) @@ -48,6 +50,7 @@ public final class ShaderHelper { manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG); doppleganger = createProgram(LibResources.SHADER_DOPLLEGANGER_VERT, LibResources.SHADER_DOPLLEGANGER_FRAG); halo = createProgram(null, LibResources.SHADER_HALO_FRAG); + dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG); } public static void useShader(int shader, ShaderCallback callback) { @@ -187,7 +190,4 @@ public final class ShaderHelper { return source.toString(); } - public static abstract class ShaderCallback { - public abstract void call(int shader); - } } diff --git a/MODSRC/vazkii/botania/client/lib/LibResources.java b/MODSRC/vazkii/botania/client/lib/LibResources.java index d2d6d5a52..2bcc38e80 100644 --- a/MODSRC/vazkii/botania/client/lib/LibResources.java +++ b/MODSRC/vazkii/botania/client/lib/LibResources.java @@ -37,6 +37,7 @@ public final class LibResources { public static final String GUI_SHEDDING_OVERLAY = PREFIX_GUI + "sheddingOverlay.png"; 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_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png"; @@ -108,5 +109,6 @@ public final class LibResources { public static final String SHADER_DOPLLEGANGER_VERT = PREFIX_SHADER + "doppleganger.vert"; public static final String SHADER_DOPLLEGANGER_FRAG = PREFIX_SHADER + "doppleganger.frag"; public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag"; + public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag"; } diff --git a/MODSRC/vazkii/botania/client/render/entity/RenderDoppleganger.java b/MODSRC/vazkii/botania/client/render/entity/RenderDoppleganger.java index 0f309e59c..bcb6d3a09 100644 --- a/MODSRC/vazkii/botania/client/render/entity/RenderDoppleganger.java +++ b/MODSRC/vazkii/botania/client/render/entity/RenderDoppleganger.java @@ -20,8 +20,9 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.ARBShaderObjects; +import vazkii.botania.api.internal.ShaderCallback; +import vazkii.botania.client.core.handler.BossBarHandler; import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.core.helper.ShaderHelper.ShaderCallback; import vazkii.botania.common.entity.EntityDoppleganger; public class RenderDoppleganger extends RenderBiped { @@ -50,7 +51,7 @@ public class RenderDoppleganger extends RenderBiped { @Override public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { EntityDoppleganger dopple = (EntityDoppleganger) par1Entity; - BossStatus.setBossStatus(dopple, true); + BossBarHandler.setCurrentBoss(dopple); if(dopple.getInvulTime() > 0) { grainIntensity = dopple.getInvulTime() > 20 ? 1F : dopple.getInvulTime() * 0.05F; diff --git a/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java b/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java index 9a4e324f4..47ec63b48 100644 --- a/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java +++ b/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java @@ -20,8 +20,8 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.ARBShaderObjects; import org.lwjgl.opengl.GL11; +import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.core.helper.ShaderHelper.ShaderCallback; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelPixie; import vazkii.botania.common.entity.EntityPixie; diff --git a/MODSRC/vazkii/botania/common/core/handler/InternalMethodHandler.java b/MODSRC/vazkii/botania/common/core/handler/InternalMethodHandler.java index 4e1a94476..23aaea75e 100644 --- a/MODSRC/vazkii/botania/common/core/handler/InternalMethodHandler.java +++ b/MODSRC/vazkii/botania/common/core/handler/InternalMethodHandler.java @@ -21,7 +21,9 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.internal.DummyMethodHandler; import vazkii.botania.api.internal.IManaNetwork; import vazkii.botania.api.lexicon.LexiconPage; @@ -29,6 +31,7 @@ import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipeRuneAltar; +import vazkii.botania.client.core.handler.BossBarHandler; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; @@ -149,6 +152,16 @@ public class InternalMethodHandler extends DummyMethodHandler { public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { Botania.proxy.sparkleFX(world, x, y, z, r, g, b, size, m); } + + @Override + public ResourceLocation getDefaultBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + BossBarHandler.setCurrentBoss(status); + } @Override public boolean shouldForceCheck() { diff --git a/MODSRC/vazkii/botania/common/entity/EntityDoppleganger.java b/MODSRC/vazkii/botania/common/entity/EntityDoppleganger.java index 4bcd628b9..e2677ec99 100644 --- a/MODSRC/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/MODSRC/vazkii/botania/common/entity/EntityDoppleganger.java @@ -11,10 +11,13 @@ */ package vazkii.botania.common.entity; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.lwjgl.opengl.ARBShaderObjects; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; @@ -32,16 +35,24 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; +import vazkii.botania.api.boss.IBotaniaBoss; +import vazkii.botania.api.boss.IBotaniaBossWithShader; +import vazkii.botania.api.internal.ShaderCallback; +import vazkii.botania.client.core.handler.BossBarHandler; +import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibObfuscation; import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class EntityDoppleganger extends EntityCreature implements IBossDisplayData { +public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWithShader { public static final int SPAWN_TICKS = 100; @@ -380,4 +391,62 @@ public class EntityDoppleganger extends EntityCreature implements IBossDisplayDa return true; } } + + @Override + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture() { + return BossBarHandler.defaultBossBar; + } + + @SideOnly(Side.CLIENT) + private static final Rectangle barRect = new Rectangle(0, 0, 185, 15); + @SideOnly(Side.CLIENT) + private static final Rectangle hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect() { + return barRect; + } + + @Override + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect() { + return hpBarRect; + } + + @Override + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback() { + // NO-OP + } + + @Override + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background) { + return background ? 0 : ShaderHelper.dopplegangerBar; + } + + @SideOnly(Side.CLIENT) + private final ShaderCallback shaderCallback = new ShaderCallback() { + + @Override + public void call(int shader) { + int grainIntensityUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "grainIntensity"); + int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "hpFract"); + + float time = getInvulTime(); + float grainIntensity = time > 20 ? 1F : time / 20F; + + ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity); + ARBShaderObjects.glUniform1fARB(hpFractUniform, (float) getHealth() / (float) getMaxHealth()); + } + + }; + + @Override + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { + return background ? null : shaderCallback; + } } diff --git a/resources/assets/botania/shader/doppleganger.frag b/resources/assets/botania/shader/doppleganger.frag index 2f45f1d6c..56a0b0cd9 100644 --- a/resources/assets/botania/shader/doppleganger.frag +++ b/resources/assets/botania/shader/doppleganger.frag @@ -15,8 +15,6 @@ void main() { float gs = (color.r + color.g + color.b) / 50.0; - vec2 seed = texcoord.xy * time; - float r = gs + rand(texcoord) * grainIntensity; float g = gs + rand(texcoord) * grainIntensity; float b = gs + rand(texcoord) * grainIntensity; diff --git a/resources/assets/botania/shader/doppleganger_bar.frag b/resources/assets/botania/shader/doppleganger_bar.frag new file mode 100644 index 000000000..0c7ce5dbd --- /dev/null +++ b/resources/assets/botania/shader/doppleganger_bar.frag @@ -0,0 +1,50 @@ +#version 120 + +uniform sampler2D bgl_RenderedTexture; +uniform int time; // Passed in, see ShaderHelper.java + +uniform int startX; // Passed in, see BossBarHandler.java +uniform int startY; // Passed in, see BossBarHandler.java + +uniform float grainIntensity; // Passed in via Callback +uniform float hpFract; + +float rand(vec2 co) { + return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453); +} + +void main() { + vec2 texcoord = vec2(gl_TexCoord[0]); + vec4 color = texture2D(bgl_RenderedTexture, texcoord); + + float r = color.r; + float g = color.g; + float b = color.b; + + float s = sin((texcoord.y + 0.0375) * 100.0 + sin(texcoord.x * 90.0 - time / 2.0) * hpFract) * 0.5 + 0.5; + s = 1F - s; + if(s <= 0.98) + s = 0; + s *= 0.4; + + r = min(1, r + s); + g = min(1, g + s); + b = min(1, b + s); + + if(hpFract <= 0.5) { + float flash = (sin(time * 2.0) - 0.8) * 5; + if(flash > 0) { + g = max(0, g - flash); + b = max(0, b - flash); + } + } + + if(grainIntensity > 0) { + float gs = rand(vec2(texcoord.x + time, texcoord.y)); + r = r * (1 - grainIntensity) + gs * grainIntensity; + g = g * (1 - grainIntensity) + gs * grainIntensity; + b = b * (1 - grainIntensity) + gs * grainIntensity; + } + + gl_FragColor = vec4(r, g, b, color.a); +} \ No newline at end of file diff --git a/resources/assets/botania/textures/gui/bossBar.png b/resources/assets/botania/textures/gui/bossBar.png new file mode 100644 index 000000000..64ab0b892 Binary files /dev/null and b/resources/assets/botania/textures/gui/bossBar.png differ