Search in sources :

Example 1 with IMixinEntityFX

use of cc.hyperium.mixins.client.particle.IMixinEntityFX in project Hyperium by HyperiumClient.

the class ParticleAuraHandler method renderPlayer.

@InvokeEvent
public void renderPlayer(RenderPlayerEvent event) {
    if (Minecraft.getMinecraft().isGamePaused())
        return;
    if (event.getEntity().isInvisible())
        return;
    if (Minecraft.getMinecraft().currentScreen instanceof GuiHyperiumScreenIngameMenu)
        return;
    if (Minecraft.getMinecraft().theWorld == null || Minecraft.getMinecraft().thePlayer == null)
        return;
    if (!Settings.SHOW_PARTICLES)
        return;
    AbstractClientPlayer entity = event.getEntity();
    if (!entity.equals(Minecraft.getMinecraft().thePlayer) && (entity.posX != entity.prevPosZ || entity.posY != entity.prevPosY || entity.posZ != entity.prevPosZ)) {
        return;
    }
    ParticleAura particleAura = auras.get(entity.getUniqueID());
    if (particleAura != null && !entity.isInvisible()) {
        double x = entity.prevPosX + (entity.posX - entity.prevPosX) * event.getPartialTicks();
        double y = entity.posY + (entity.posY - entity.prevPosY) * event.getPartialTicks();
        double z = entity.posZ + (entity.posZ - entity.prevPosZ) * event.getPartialTicks();
        List<Vec3> render = particleAura.render(entity, x, y, z);
        render.forEach(vec3 -> {
            IParticle type = particleAura.getType();
            if (type != null) {
                EntityFX entityFX = type.spawn(entity.worldObj, vec3.xCoord, vec3.yCoord, vec3.zCoord);
                int particleMaxAge = particleAura.getParticleMaxAge();
                IMixinEntityFX e = (IMixinEntityFX) entityFX;
                if (particleAura.isChroma()) {
                    int i = Color.HSBtoRGB(System.currentTimeMillis() % 1000L / 1000.0f, 0.8f, 0.8f);
                    Color color = new Color(i);
                    entityFX.setRBGColorF(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
                } else if (particleAura.isRgb()) {
                    entityFX.setRBGColorF(particleAura.getRed() / 255F, particleAura.getBlue() / 255F, particleAura.getBlue() / 255F);
                }
                e.setParticleGravity(10);
                e.setParticleMaxAge(particleMaxAge);
                Minecraft.getMinecraft().effectRenderer.addEffect(entityFX);
            }
        });
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) IMixinEntityFX(cc.hyperium.mixins.client.particle.IMixinEntityFX) GuiHyperiumScreenIngameMenu(cc.hyperium.gui.GuiHyperiumScreenIngameMenu) Vec3(net.minecraft.util.Vec3) IMixinEntityFX(cc.hyperium.mixins.client.particle.IMixinEntityFX) EntityFX(net.minecraft.client.particle.EntityFX) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

InvokeEvent (cc.hyperium.event.InvokeEvent)1 GuiHyperiumScreenIngameMenu (cc.hyperium.gui.GuiHyperiumScreenIngameMenu)1 IMixinEntityFX (cc.hyperium.mixins.client.particle.IMixinEntityFX)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 EntityFX (net.minecraft.client.particle.EntityFX)1 Vec3 (net.minecraft.util.Vec3)1