Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect.

But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)

 

I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated

This honestly might just work for you

@SubscribeEvent
public static void onScreenRender(ScreenEvent.Render.Post event) {
final var player = Minecraft.getInstance().player;
            final var options = Minecraft.getInstance().options;
            if(!hasMyEffect(player)) return; // TODO: You provide hasMyEffect

            float f = Mth.lerp(event.getPartialTick(), player.oSpinningEffectIntensity, player.spinningEffectIntensity);
            float f1 = ((Double)options.screenEffectScale().get()).floatValue();
            if(f <= 0F || f1 >= 1F) return;

            float p_282656_ = f * (1.0F - f1);
            final var p_282460_ = event.getGuiGraphics();
            int i = p_282460_.guiWidth();
            int j = p_282460_.guiHeight();
            p_282460_.pose().pushPose();
            float f5 = Mth.lerp(p_282656_, 2.0F, 1.0F);
            p_282460_.pose().translate((float)i / 2.0F, (float)j / 2.0F, 0.0F);
            p_282460_.pose().scale(f5, f5, f5);
            p_282460_.pose().translate((float)(-i) / 2.0F, (float)(-j) / 2.0F, 0.0F);
            float f4 = 0.2F * p_282656_;
            float f2 = 0.4F * p_282656_;
            float f3 = 0.2F * p_282656_;
            RenderSystem.disableDepthTest();
            RenderSystem.depthMask(false);
            RenderSystem.enableBlend();
            RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
            p_282460_.setColor(f4, f2, f3, 1.0F);
            p_282460_.blit(new ResourceLocation("textures/misc/nausea.png"), 0, 0, -90, 0.0F, 0.0F, i, j, i, j);
            p_282460_.setColor(1.0F, 1.0F, 1.0F, 1.0F);
            RenderSystem.defaultBlendFunc();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.enableDepthTest();
            p_282460_.pose().popPose();
}

 

Note: Most of this is directly copied from GameRenderer as you pointed out you found.

The only thing you'll have to likely do is update the `oSpinningEffectIntensity` + `spinningEffectIntensity` variables on the player when your effect is applied. Which values should be there? Not 100% sure, might be a game of guess and check, but `handleNetherPortalClient` in LocalPlayer has some hard coded you might be able to start with.

Edited by dee12452
Fixed broken code

  • Author
On 4/19/2024 at 4:13 PM, dee12452 said:

This honestly might just work for you

@SubscribeEvent
public static void onScreenRender(ScreenEvent.Render.Post event) {
final var player = Minecraft.getInstance().player;
            final var options = Minecraft.getInstance().options;
            if(!hasMyEffect(player)) return; // TODO: You provide hasMyEffect

            float f = Mth.lerp(event.getPartialTick(), player.oSpinningEffectIntensity, player.spinningEffectIntensity);
            float f1 = ((Double)options.screenEffectScale().get()).floatValue();
            if(f <= 0F || f1 >= 1F) return;

            float p_282656_ = f * (1.0F - f1);
            final var p_282460_ = event.getGuiGraphics();
            int i = p_282460_.guiWidth();
            int j = p_282460_.guiHeight();
            p_282460_.pose().pushPose();
            float f5 = Mth.lerp(p_282656_, 2.0F, 1.0F);
            p_282460_.pose().translate((float)i / 2.0F, (float)j / 2.0F, 0.0F);
            p_282460_.pose().scale(f5, f5, f5);
            p_282460_.pose().translate((float)(-i) / 2.0F, (float)(-j) / 2.0F, 0.0F);
            float f4 = 0.2F * p_282656_;
            float f2 = 0.4F * p_282656_;
            float f3 = 0.2F * p_282656_;
            RenderSystem.disableDepthTest();
            RenderSystem.depthMask(false);
            RenderSystem.enableBlend();
            RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
            p_282460_.setColor(f4, f2, f3, 1.0F);
            p_282460_.blit(new ResourceLocation("textures/misc/nausea.png"), 0, 0, -90, 0.0F, 0.0F, i, j, i, j);
            p_282460_.setColor(1.0F, 1.0F, 1.0F, 1.0F);
            RenderSystem.defaultBlendFunc();
            RenderSystem.disableBlend();
            RenderSystem.depthMask(true);
            RenderSystem.enableDepthTest();
            p_282460_.pose().popPose();
}

 

Note: Most of this is directly copied from GameRenderer as you pointed out you found.

The only thing you'll have to likely do is update the `oSpinningEffectIntensity` + `spinningEffectIntensity` variables on the player when your effect is applied. Which values should be there? Not 100% sure, might be a game of guess and check, but `handleNetherPortalClient` in LocalPlayer has some hard coded you might be able to start with.

Yeah i had something similar and the same problem is happening:It only triggers when in a gui (pause menu, inventory etc) is on the screen. So that was my main need of help. Do i need to make "a class to render the effect on", if that makes sense? Thanks for the render code though, with a few tweaks it will look amazing.

EDIT: If im not mistaken that's the expected result of the event used? But as I said this is my first time tinkering with player-side rendering.

Edited by chxr
Typos

  • Author

Changing the event to RenderGuiEvent.post  kinda did the trick. If there is any more suitable events please tell me, and thanks for the help!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.