Overlay à la "pumkinBlur"



  • Yellow !
    Je suis encore là pour vous poser encore un de mes problèmes, hélas !

    J'essaie de faire un overlay de sang, comme le "pumpkinBlur" avec ces codes:
    :::

    package zeamateis.viruz.client;
    
    import java.util.EnumSet;
    
    import org.lwjgl.opengl.GL11;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.ScaledResolution;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import cpw.mods.fml.common.ITickHandler;
    import cpw.mods.fml.common.TickType;
    
    public class ClientTicks implements ITickHandler
    {
    ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft().gameSettings, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    
    public void tickStart(EnumSet <ticktype>type, Object… tickData)//Debut Tick
    {
    }
    
    public void tickEnd(EnumSet <ticktype>type, Object... tickData)//Fin Tick
    {
    if(type.equals(EnumSet.of(TickType.RENDER)))
    {
    playerLowLifeOverlay((EntityPlayer)tickData[0]);
    }
    }
    
    @Override
    public EnumSet <ticktype>ticks()
    {
    return EnumSet.of(TickType.PLAYER, TickType.RENDER, TickType.CLIENT);
    }
    
    private void playerLowLifeOverlay(EntityPlayer player)
    {
    int k = scaledresolution.getScaledWidth();
    int l = scaledresolution.getScaledHeight();
    
    if (Minecraft.getMinecraft().thePlayer.getHealth() < 3)
    {
    this.renderOverlaySang(k, l);
    }
    }
    
    protected void renderOverlaySang(int par1, int par2)
    {
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    Minecraft.getMinecraft().renderEngine.bindTexture("%blur%/misc/pumpkinblur.png");
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);
    tessellator.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);
    tessellator.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);
    tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
    
    @Override
    public String getLabel() {
    return "";}
    }
    

    :::

    Et le code d'erreur qui va bien:
    :::

    2013-12-29 21:05:40 [Infos] [ForgeModLoader] Forge Mod Loader version 5.2.23.738 for Minecraft 1.5.2 loading
    2013-12-29 21:05:40 [Infos] [ForgeModLoader] Java is Java HotSpot(TM) Client VM, version 1.7.0_45, running on Windows 8:x86:6.2, installed at C:\Program Files (x86)\Java\jre7
    2013-12-29 21:05:40 [Infos] [ForgeModLoader] Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
    2013-12-29 21:05:42 [Infos] [STDOUT] 229 recipes
    2013-12-29 21:05:42 [Infos] [STDOUT] 27 achievements
    2013-12-29 21:05:42 [Infos] [Minecraft-Client] Setting user: Survivant609
    2013-12-29 21:05:42 [Infos] [STDOUT] (Session ID is -)
    2013-12-29 21:05:42 [Infos] [STDERR] Client asked for parameter: server
    2013-12-29 21:05:42 [Infos] [Minecraft-Client] LWJGL Version: 2.4.2
    2013-12-29 21:05:43 [Infos] [MinecraftForge] Attempting early MinecraftForge initialization
    2013-12-29 21:05:43 [Infos] [STDOUT] MinecraftForge v7.8.1.738 Initialized
    2013-12-29 21:05:43 [Infos] [ForgeModLoader] MinecraftForge v7.8.1.738 Initialized
    2013-12-29 21:05:43 [Infos] [STDOUT] Replaced 85 ore recipies
    2013-12-29 21:05:43 [Infos] [MinecraftForge] Completed early MinecraftForge initialization
    2013-12-29 21:05:43 [Infos] [ForgeModLoader] Reading custom logging properties from C:\Users\Jean-Baptiste\Desktop\Modding\JAVA\MCP ViruZBaseMod\jars\config\logging.properties
    2013-12-29 21:05:43 [Désactivé] [ForgeModLoader] Logging level for ForgeModLoader logging is set to ALL
    2013-12-29 21:05:44 [Infos] [ForgeModLoader] Searching C:\Users\Jean-Baptiste\Desktop\Modding\JAVA\MCP ViruZBaseMod\jars\mods for mods
    2013-12-29 21:05:45 [Infos] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load
    2013-12-29 21:05:45 [Infos] [mcp] Activating mod mcp
    2013-12-29 21:05:45 [Infos] [FML] Activating mod FML
    2013-12-29 21:05:45 [Infos] [Forge] Activating mod Forge
    2013-12-29 21:05:45 [Infos] [ViruZ] Activating mod ViruZ
    2013-12-29 21:05:45 [Infos] [ForgeModLoader] Registering Forge Packet Handler
    2013-12-29 21:05:45 [Infos] [ForgeModLoader] Succeeded registering Forge Packet Handler
    2013-12-29 21:05:45 [Infos] [ForgeModLoader] Configured a dormant chunk cache size of 0
    2013-12-29 21:05:46 [Infos] [STDOUT]
    2013-12-29 21:05:46 [Infos] [STDOUT] Starting up SoundSystem…
    2013-12-29 21:05:46 [Infos] [STDOUT] Initializing LWJGL OpenAL
    2013-12-29 21:05:46 [Infos] [STDOUT] (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org)
    2013-12-29 21:05:46 [Infos] [STDOUT] OpenAL initialized.
    2013-12-29 21:05:46 [Infos] [STDOUT]
    2013-12-29 21:05:47 [Avertissement] [Minecraft-Client] TextureManager.createTexture called for file textures/blocks/phareOn.png, but that file does not exist. Ignoring.
    2013-12-29 21:05:47 [Avertissement] [Minecraft-Client] TextureManager.createTexture called for file textures/blocks/phareOff.png, but that file does not exist. Ignoring.
    2013-12-29 21:05:47 [Infos] [ForgeModLoader] Forge Mod Loader has detected an older LWJGL version, new advanced texture animation features are disabled
    2013-12-29 21:05:47 [Infos] [ForgeModLoader] Not using advanced OpenGL 4.3 advanced capability for animations : OpenGL 4.3 is not available
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/lava_flow.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/water_flow.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/fire_0.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/fire_1.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/lava.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/portal.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/water.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/items/clock.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/items/compass.txt
    2013-12-29 21:05:47 [Infos] [ForgeModLoader] Forge Mod Loader has successfully loaded 4 mods
    2013-12-29 21:05:47 [Avertissement] [Minecraft-Client] TextureManager.createTexture called for file textures/blocks/phareOn.png, but that file does not exist. Ignoring.
    2013-12-29 21:05:47 [Avertissement] [Minecraft-Client] TextureManager.createTexture called for file textures/blocks/phareOff.png, but that file does not exist. Ignoring.
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/lava_flow.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/water_flow.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/fire_0.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/fire_1.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/lava.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/portal.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/blocks/water.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/items/clock.txt
    2013-12-29 21:05:47 [Infos] [Minecraft-Client] Found animation info for: textures/items/compass.txt
    2013-12-29 21:05:49 [Infos] [STDERR] java.lang.ClassCastException: java.lang.Float cannot be cast to net.minecraft.entity.player.EntityPlayer
    2013-12-29 21:05:49 [Infos] [STDERR] at zeamateis.viruz.client.ClientTicks.tickEnd(ClientTicks.java:28)
    2013-12-29 21:05:49 [Infos] [STDERR] at cpw.mods.fml.common.SingleIntervalHandler.tickEnd(SingleIntervalHandler.java:34)
    2013-12-29 21:05:49 [Infos] [STDERR] at cpw.mods.fml.common.FMLCommonHandler.tickEnd(FMLCommonHandler.java:141)
    2013-12-29 21:05:49 [Infos] [STDERR] at cpw.mods.fml.common.FMLCommonHandler.onRenderTickEnd(FMLCommonHandler.java:377)
    2013-12-29 21:05:49 [Infos] [STDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:873)
    2013-12-29 21:05:49 [Infos] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:760)
    2013-12-29 21:05:49 [Infos] [STDERR] at java.lang.Thread.run(Unknown Source)
    2013-12-29 21:05:59 [Infos] [Minecraft-Client] Stopping!
    2013-12-29 21:05:59 [Infos] [STDOUT]
    2013-12-29 21:05:59 [Infos] [STDOUT] SoundSystem shutting down…
    2013-12-29 21:05:59 [Infos] [STDOUT] Author: Paul Lamb, www.paulscode.com
    2013-12-29 21:05:59 [Infos] [STDOUT]
    
    

    :::

    Le problème viens du fait qu'un float ne peut pas être cast au Player, il me semble ?
    Mais alors, je vois pas comment le régler…</ticktype></ticktype></ticktype>



  • java.lang.ClassCastException: java.lang.Float cannot be cast to net.minecraft.entity.player.EntityPlayer

    Alors, en gros, tu essaie de faire en sorte que tickData, qui est un float devienne un EntityPlayer …

    Essaie d'enlever le cast d'EntityPlayer


  • Administrateurs

    Pour un rendu d'overlay, il faudrait plutôt utiliser RenderGameOverlayEvent.

    ÉDIT :

    En passant j'ai refais l'event de nanotech_mod :
    https://github.com/FFMT/nanotech_mod/blob/master/common/fr/mcnanotech/kevin_68/nanotech_mod/main/event/RenderEvent.java#L22



  • J'ai ce problème une fois l'event utilisé :

    http://puu.sh/62RSL.png il ne s'active qu'a ma mort


  • Administrateurs

    Étrange, envoie ton code.



  • :::

    
    package zeamateis.viruz.manage;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.ScaledResolution;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.item.ItemStack;
    import net.minecraftforge.client.event.RenderGameOverlayEvent;
    import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
    import net.minecraftforge.event.ForgeSubscribe;
    
    import org.lwjgl.opengl.GL11;
    
    public class RenderOverlayManager
    {
    private Minecraft mc = Minecraft.getMinecraft();
    
    @ForgeSubscribe
    public void onRenderGameOverlay(RenderGameOverlayEvent event)
    {
    if(this.mc.thePlayer.getHealth() < 5)
    {
    int k = event.resolution.getScaledWidth();
    int l = event.resolution.getScaledHeight();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    this.mc.renderEngine.bindTexture("%blur%/misc/pumpkinblur.png");
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, (double)l, -90.0D, 0.0D, 1.0D);
    tessellator.addVertexWithUV((double)k, (double)l, -90.0D, 1.0D, 1.0D);
    tessellator.addVertexWithUV((double)k, 0.0D, -90.0D, 1.0D, 0.0D);
    tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
    }
    
    

    }
    :::


  • Administrateurs

    Je viens de tester avec la même condition que toi, ça fonctionne très bien.
    Tu es sur que tu avais 2 cœurs ou moins lors du test ?



  • oui, je vais re-tester

    EDIT:

    Cela marche ! C'est parce-que je suis mort avant qu'il apparaisse !

    RÉSOLU


Log in to reply