Add visual first person blink effect
This commit is contained in:
@@ -44,6 +44,7 @@ import net.minecraftforge.client.event.RenderLivingEvent;
|
|||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
@@ -66,9 +67,29 @@ public final class WizardryClientEventHandler {
|
|||||||
private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/sixth_sense.png");
|
private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/sixth_sense.png");
|
||||||
private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/sixth_sense_overlay.png");
|
private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/sixth_sense_overlay.png");
|
||||||
private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_overlay.png");
|
private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_overlay.png");
|
||||||
|
private static final ResourceLocation blinkOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/blink_overlay.png");
|
||||||
private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/pointer.png");
|
private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/pointer.png");
|
||||||
private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/target_pointer.png");
|
private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/target_pointer.png");
|
||||||
|
|
||||||
|
/** The remaining time for which the blink screen overlay effect will be displayed in first-person. Since this is
|
||||||
|
* only for the first-person player (the instance of which is itself stored in a static variable), this can simply
|
||||||
|
* be stored statically here, rather than needing to be in {@code WizardData}. */
|
||||||
|
private static int blinkEffectTimer;
|
||||||
|
/** The number of ticks the blink effect lasts for. */
|
||||||
|
private static final int BLINK_EFFECT_DURATION = 8;
|
||||||
|
|
||||||
|
/** Starts the first person blink overlay effect. */
|
||||||
|
public static void playBlinkEffect(){
|
||||||
|
blinkEffectTimer = BLINK_EFFECT_DURATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onLivingUpdateEvent(LivingUpdateEvent event){
|
||||||
|
if(event.getEntity() == Minecraft.getMinecraft().player){
|
||||||
|
if(blinkEffectTimer > 0) blinkEffectTimer--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTextureStitchEvent(TextureStitchEvent.Pre event){
|
public static void onTextureStitchEvent(TextureStitchEvent.Pre event){
|
||||||
|
|
||||||
@@ -129,6 +150,11 @@ public final class WizardryClientEventHandler {
|
|||||||
|
|
||||||
event.setNewfov(event.getFov() * 1.0F - maxUseSeconds * 0.15F);
|
event.setNewfov(event.getFov() * 1.0F - maxUseSeconds * 0.15F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(blinkEffectTimer > 0){
|
||||||
|
float f = ((float)Math.max(blinkEffectTimer - 2, 0))/BLINK_EFFECT_DURATION;
|
||||||
|
event.setNewfov(event.getFov() + f * f * 0.7f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Brute-force fix for crystals not showing up when a wizard is given a spell book in the trade GUI.
|
// Brute-force fix for crystals not showing up when a wizard is given a spell book in the trade GUI.
|
||||||
@@ -354,66 +380,72 @@ public final class WizardryClientEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onRenderGameOverlayEvent(RenderGameOverlayEvent.Post event){
|
public static void onRenderGameOverlayEvent(RenderGameOverlayEvent.Post event){
|
||||||
|
|
||||||
if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET
|
if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET){
|
||||||
&& Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.sixth_sense)){
|
|
||||||
|
if(Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.sixth_sense)){
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
|
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||||
GlStateManager.disableDepth();
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.disableAlpha();
|
||||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
renderScreenOverlay(event, sixthSenseOverlayTexture);
|
||||||
GlStateManager.disableAlpha();
|
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(sixthSenseOverlayTexture);
|
GlStateManager.enableAlpha();
|
||||||
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
}
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
|
||||||
|
if(Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.frost)){
|
||||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
|
||||||
buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex();
|
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||||
buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D)
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
.endVertex();
|
GlStateManager.disableAlpha();
|
||||||
buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex();
|
|
||||||
buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex();
|
renderScreenOverlay(event, frostOverlayTexture);
|
||||||
tessellator.draw();
|
|
||||||
|
GlStateManager.enableAlpha();
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
GlStateManager.enableDepth();
|
}
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
if(blinkEffectTimer > 0){
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
float alpha = ((float)blinkEffectTimer)/BLINK_EFFECT_DURATION;
|
||||||
|
|
||||||
|
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
|
||||||
|
GlStateManager.color(1, 1, 1, alpha);
|
||||||
|
GlStateManager.disableAlpha();
|
||||||
|
|
||||||
|
renderScreenOverlay(event, blinkOverlayTexture);
|
||||||
|
|
||||||
|
GlStateManager.enableAlpha();
|
||||||
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void renderScreenOverlay(RenderGameOverlayEvent.Post event, ResourceLocation texture){
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET && Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.frost)){
|
GlStateManager.disableDepth();
|
||||||
|
GlStateManager.depthMask(false);
|
||||||
|
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
BufferBuilder buffer = tessellator.getBuffer();
|
||||||
|
|
||||||
GlStateManager.disableDepth();
|
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||||
GlStateManager.depthMask(false);
|
buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex();
|
||||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D)
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
.endVertex();
|
||||||
GlStateManager.disableAlpha();
|
buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex();
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(frostOverlayTexture);
|
buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex();
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
GlStateManager.depthMask(true);
|
||||||
|
GlStateManager.enableDepth();
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
GlStateManager.popMatrix();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
|
||||||
|
|
||||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
|
||||||
buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex();
|
|
||||||
buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D)
|
|
||||||
.endVertex();
|
|
||||||
buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex();
|
|
||||||
buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex();
|
|
||||||
|
|
||||||
tessellator.draw();
|
|
||||||
GlStateManager.depthMask(true);
|
|
||||||
GlStateManager.enableDepth();
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Something in here is making the first person shadow ward rather translucent.
|
// FIXME: Something in here is making the first person shadow ward rather translucent.
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class Banish extends SpellRay {
|
|||||||
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
|
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
|
||||||
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can't be bothered to route this through the proxies!
|
||||||
|
if(entity == net.minecraft.client.Minecraft.getMinecraft().player)
|
||||||
|
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y > -1){
|
if(y > -1){
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public class Blink extends Spell {
|
|||||||
world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5,
|
world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5,
|
||||||
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can't be bothered to route this through the proxies!
|
||||||
|
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
|
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ public class PhaseStep extends Spell {
|
|||||||
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
|
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
|
||||||
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can't be bothered to route this through the proxies!
|
||||||
|
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user