Jump to content

[1.8.9] Fade to black Gui


Recommended Posts

Hello, what I am trying to do, Is for my elevator mod, have the player's screen fade to black, then teleport the player to another floor, then fade the black out. I did see a post regarding something similar, regarding a similar effect when you start losing air under water. Using what I saw there, I attempted two of the methods listed there but I could use some more input in to how I would go about implementing it. That page can be found here. The code that I have atm are as follows


public static void renderBlindness(){
		ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
        int i = scaledresolution.getScaledWidth();
        int j = scaledresolution.getScaledHeight();
        int j1 = 10;
        float f1 = (float)j1 / 100.0F;

        if (f1 > 1.0F)
            f1 = 1.0F - (float)(j1 - 100) / 10.0F;

        int k = (int)(220.0F * f1) << 24 | 1052704;
        drawRect(0, 0, i, j, k);


With this code I am at a fault for trying to figure out how to have it render properly. But that is only a slightly modified version of the way that vanilla minecraft does the fade for the bed.

This is the other code that is my attempt to mess with the blindness potion effect:

	public void fogDensity(FogDensity event){
		if(event.entity instanceof EntityLiving){
			EntityLiving entity = (EntityLiving)event.entity;
			PotionEffect effect = entity.getActivePotionEffect(Potion.blindness);
			if(effect != null && effect.getAmplifier() == 255){
				event.density = 2;

What I was trying to get that to do, is when a player has the blindness effect with an amplifier of 255 to change the density. but I didn't see much change when I tested in the debug mode. 
Anyways, The way that I had attempted to run the first one, was just calling it before the method to teleport the player to the other elevators. The second one was registered (I may have done it the wrong way, as it has been a while since the last time I have coded) but I just used "FMLCommonHandler.instance().bus().register()" to register the FogDensity. 


Any help is welcome, feel free to give me constructive advice on what I can do better, this is my attempt to get my 1.7.10 mod upgraded for all the versions, I have builds for each version (1.8.9, 1.9, 1.9.4, 1.10.2, 1.12.2) but there are some bugs I need to iron out, and I was hoping to add this black out method to them when I update. 



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.

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.


  • Create New...

Important Information

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