Topic category: Help with Minecraft modding (Java Edition)
Hello! I have managed to make a crude oil custom fluid for my mod. I've also made it so when the player is under it, they begin to drown and a dark, almost opaque screen overlay is shown. However, i have realized that the overlay doesn't really give the desired effect. I want an effect more similar to that of lava. For that, i need to make it so that a sort of fog appears when the player is under the fluid.
For that, i have made a custom mod element, as i haven't really found a way to do this through the MCreator GUI. I am an experienced programmer, just not minecraft modding which is why i'm using MCreator in the first place. I've read through forge documentation trying to figure out how to achieve this, i can't say i really understand what i'm doing because i've never even touched forge or any other minecraft modding tool/library. My problem is that MCreator fails to compile my mod because it cannot find a certain forge package, even though according to the documentation i've read, it should exist.
Here is the package that can't be found:
net.minecraftforge.client.event.EntityViewRenderEvent
i need to import that package to do something like this:
@SubscribeEvent
public void onRenderFog(FogDensity event) {
event.setDensity(1);
}
which according to forge documentation, should set a fog density. A similar method can be used to set a fog color, and from what i've read, i can add in an if statement to check if the player is under the liquid to make the fog only show if that's the case.
When compiling, i get an error saying that net.minecraftforge.client.event.EntityViewRenderEvent
cannot be found and that by consequence, FogDensity
cannot be found either. There is very little information about this on the web, so i'm hoping that someone in here has enough expertise to know what's going on. I've tried clearing my gradle cache and restarting MCreator but the problem persists.
First of all: What Minecraft version are you making the mod for? I'm going to assume you're on 1.19 since I'm having the same problem there and since It's the latest supported version.
Anyways: I'm trying to do something similar, and after a lot of digging through events, it seems like
EntityViewRenderEvent
has been removed and changed toViewportEvent
.I think I have mostly figured out the general way that this new system works, however none of the code below actually works, but I'll include it since maybe it's enough for you to figure out how to get it working.
Now, I'm pretty sure this is the general idea of how to change the fog with this:
I can't find anything in
ViewportEvent
for explicitly changing fog density, but the alpha value offogColor
might be what controls the density now:Like I said though, I haven't managed to get it working since nothing about the fog changes, but maybe I'm just being stupid.
You can also change all these properties either with
event.something()
ORRenderSystem.something()
(for exampleevent.setNearPlaneDistance()
orRenderSystem.setShaderFogStart()
), and I'm not sure which one is better since neither of them have worked for me so far.TL:DR,
EntityViewRenderEvent
is nowViewportEvent
, but I have no idea how to use it so that's all I know.Forge documentation:
ViewportEvent.RenderFog: https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.19.3/net/minecraftforge/client/event/ViewportEvent.RenderFog.html
ViewportEvent.ComputeFogColor: https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.19.3/net/minecraftforge/client/event/ViewportEvent.ComputeFogColor.html
Hopefully you can manage to figure it out, and let me know if you do since I need it for something similar lol.
Good luck!