Jump to content

[1.15.2] How is blindness processed?


Novârch

Recommended Posts

I'm trying to make a potion effect that combines a few vanilla potion effects, the purpose being being able to easily remove it without removing effects the player might have had prior to getting it, one of these effects is blindness. How does the blindness effect work? Does the game check whether you have it while rendering, can I replicate it's functionality with an event?

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

The effect is controlled by FogRenderer#updateFogColor, and FogRenderer#setupFog. Look for the usages of Effects.BLINDNESS to see the exact math it performs.

Hook on to the EntityViewRenderEvent$FogDensity and EntityViewRenderEvent$FogColors events to override the vanilla behavior and do your own logic (the former event will need to be canceled for your stuff to work).

I recommend using a lower event priority and then checking the state of the events so that other mods can override your system if desired.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

1 hour ago, imacatlolol said:

The effect is controlled by FogRenderer#updateFogColor, and FogRenderer#setupFog. Look for the usages of Effects.BLINDNESS to see the exact math it performs.

Hook on to the EntityViewRenderEvent$FogDensity and EntityViewRenderEvent$FogColors events to override the vanilla behavior and do your own logic (the former event will need to be canceled for your stuff to work).

I recommend using a lower event priority and then checking the state of the events so that other mods can override your system if desired.

Thanks for the help! Everything works fine except this line, and it seems that it's pretty important because nothing renders when I remove it.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

That lets other mods be notified about fog and change it if they want.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

That lets other mods be notified about fog and change it if they want.

Than I must've goofed something else up, but I don't know what because I just copied the vanilla FogRenderer code.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

1 hour ago, Novârch said:

I just copied the vanilla FogRenderer code.

There's your problem.

The event is normally intended to be used by simply setting the fog density via the event's setDensity method. The same goes for the fog color.

A density of 0.3 will produce a very similar effect as the vanilla method, but it's not perfectly identical since vanilla uses more complex methods. However, the difference is very subtle and none of your users will likely even notice.

If you really want an identical effect, you should set the density to 0 and then use those four RenderSystem method calls towards the end.

Edited by imacatlolol
Slightly better wording

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

9 hours ago, imacatlolol said:

There's your problem.

The event is normally intended to be used by simply setting the fog density via the event's setDensity method. The same goes for the fog color.

A density of 0.3 will produce a very similar effect as the vanilla method, but it's not perfectly identical since vanilla uses more complex methods. However, the difference is very subtle and none of your users will likely even notice.

If you really want an identical effect, you should set the density to 0 and then use those four RenderSystem method calls towards the end.

Thanks for the help, gotten the exact effect I was looking for!

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

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.