se37.triangulum.particles.ParticleRenderDispatcher.java Source code

Java tutorial

Introduction

Here is the source code for se37.triangulum.particles.ParticleRenderDispatcher.java

Source

/**
 * This class was created by <Vazkii>. 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 @ [Jul 2, 2014, 12:12:45 AM (GMT)]
 */

package se37.triangulum.particles;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.profiler.Profiler;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public final class ParticleRenderDispatcher {

    public static int wispFxCount = 0;
    public static int depthIgnoringWispFxCount = 0;
    public static int sparkleFxCount = 0;

    @SubscribeEvent
    public void onRenderWorldLast(RenderWorldLastEvent event) {
        Tessellator tessellator = Tessellator.getInstance();

        Profiler profiler = Minecraft.getMinecraft().mcProfiler;

        GL11.glPushAttrib(GL11.GL_LIGHTING);
        GlStateManager.depthMask(false);
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F);
        GlStateManager.disableLighting();

        profiler.startSection("psi-particles");
        profiler.startSection("sparkle");
        FXSparkle.dispatchQueuedRenders(tessellator);
        profiler.endStartSection("wisp");
        FXWisp.dispatchQueuedRenders(tessellator);
        profiler.endSection();
        profiler.endSection();

        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GL11.glPopAttrib();
    }

}