Jump to content

Recommended Posts

Posted

I cannot get the Fog color to work; along with the density. I looked at other posts, tutorials, and GitHub Repository-s but still have no idea why this won't work.

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onFogDensityEvent(EntityViewRenderEvent.FogDensity event) {
    event.setDensity(0.0001F);
    if (event.getEntity().isInsideOfMaterial(ModMaterials.MOLTEN_GLASS)) event.setDensity(1F);
}

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onFogColorsEvent(EntityViewRenderEvent.FogColors event) {
    if (event.getEntity().isInsideOfMaterial(ModMaterials.MOLTEN_GLASS)) {
        event.setRed(COLOR_MOLTEN_GLASS.getRed());
        event.setGreen(COLOR_MOLTEN_GLASS.getGreen());
        event.setBlue(COLOR_MOLTEN_GLASS.getBlue());
    }
}
private static final Color COLOR_MOLTEN_GLASS = new Color(251, 143, 70);
Posted
  On 5/7/2019 at 4:26 PM, DiamondMiner88 said:

I cannot get the Fog color to work; along with the density. I looked at other posts, tutorials, and GitHub Repository-s but still have no idea why this won't work.

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onFogDensityEvent(EntityViewRenderEvent.FogDensity event) {
    event.setDensity(0.0001F);
    if (event.getEntity().isInsideOfMaterial(ModMaterials.MOLTEN_GLASS)) event.setDensity(1F);
}

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onFogColorsEvent(EntityViewRenderEvent.FogColors event) {
    if (event.getEntity().isInsideOfMaterial(ModMaterials.MOLTEN_GLASS)) {
        event.setRed(COLOR_MOLTEN_GLASS.getRed());
        event.setGreen(COLOR_MOLTEN_GLASS.getGreen());
        event.setBlue(COLOR_MOLTEN_GLASS.getBlue());
    }
}
private static final Color COLOR_MOLTEN_GLASS = new Color(251, 143, 70);
Expand  

Did you check if events are being called?

Posted

No, how do i do that?

I placed them in my ClientEventSubscriber

  Reveal hidden contents

 

Posted
  On 5/7/2019 at 5:13 PM, DiamondMiner88 said:

No, how do i do that?

I placed them in my ClientEventSubscriber

  Reveal hidden contents

 

Expand  

Well I am not an expert, but you can do that using debugger, orrr I always do that by simply putting

System.out.println("YAY It was called, so it's working!");

inside the method I wanna check.
I would suggest putting two checks - before if and after if - so you will get double result - check if your event is actually working (is it being called) and check if entity actually is inside that material, so you will be sure that your if works correctly.

Posted

Well, if you need to check, just do the getRed/Green/Blue method and see what it returns. And if you need to convert your RGB to a value between 0-1 range, it is as simple as dividing by 255.

Posted

Hmmm.... could there be a problem with your events not being static? To be honest, not sure what the difference is between a static and non-static event is (I know the difference between static fields and methods). 

Posted (edited)

Ok That fixed it. My other event subscriptions are static, didn't notice that. Now the problem is that the color is not working.

How it looks when I'm not in the fluid:

  Reveal hidden contents

When i am in the fluid:

  Reveal hidden contents

What i have done now:

  Reveal hidden contents

 

Edited by DiamondMiner88
Posted

By default the fog density mode would be linear. You would need to change it to exponental using GlStateManager in your density hook. I also believe that the density for lava is 2, not 1.

Posted
  On 5/7/2019 at 10:35 PM, DiamondMiner88 said:

Density Hook? Whats that?

Expand  

 

  On 5/7/2019 at 8:07 PM, DiamondMiner88 said:

public static void onFogDensityEvent(EntityViewRenderEvent.FogDensity event) {

Expand  

 

  On 5/7/2019 at 10:35 PM, DiamondMiner88 said:

How do i do that?

Expand  

 

  On 5/7/2019 at 9:28 PM, V0idWa1k3r said:

using GlStateManager

Expand  

To be more specifically GlStateManager.fogMode

Posted (edited)

I have done this in my density hook but it appears to have done nothing

GlStateManager.setFog(GlStateManager.FogMode.EXP);

I haven't finished the flow texture so i just set it to be white, here's how it looks:

  Reveal hidden contents

 

Edited by DiamondMiner88
Posted
  On 5/7/2019 at 11:42 PM, DiamondMiner88 said:

I have done this in my density hook but it appears to have done nothing

GlStateManager.setFog(GlStateManager.FogMode.EXP);

I haven't finished the flow texture so i just set it to be white, here's how it looks:

  Reveal hidden contents

 

Expand  

Hmmm maybe you need to experiment with fogStart and fogEnd parameters? 

            GlStateManager.fogStart(fogStartFloat-for e.g. 4f);
            GlStateManager.fogEnd(fogEndFloat for e.g. 40f);

 

Posted

Try doing 

GlStateManager.setFogDensity(float);

Look at what Minecraft uses for water (in net.minecraft.client.renderer.EntityRenderer):

  Reveal hidden contents

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.