Posted July 29, 20223 yr Hi, I'm trying to make a custom overlay when the player has a potion effect, like in Nausea or the pumpkin. I did some research and I need the RenderGameOverlayEvent. I've declared it but It doesn't work. Maybe i have to declare it in some other place? I actually have it on event/ModEventBus @Mod.EventBusSubscriber(modid = example.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEventBusEvents { Minecraft mc = Minecraft.getInstance(); private static final ResourceLocation IMG_LOCATION = new ResourceLocation("textures/scream/glowing.png"); protected int screenWidth; protected int screenHeight; @SubscribeEvent public void HUGGYSCREAMER(RenderGameOverlayEvent event) { Player player = Minecraft.getInstance().player; //Options settings = Minecraft.getInstance().options; this.screenWidth = this.mc.getWindow().getGuiScaledWidth(); this.screenHeight = this.mc.getWindow().getGuiScaledHeight(); assert player != null; if (player.hasEffect(MobEffects.GLOWING)) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(770, 771); Minecraft.getInstance().getTextureManager().bindForSetup(IMG_LOCATION); GuiComponent.blit(event.getMatrixStack(), 0, 0, 0, 0,screenWidth ,screenHeight, 480, 270); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); } } }
July 29, 20223 yr RenderGameOverlayEvent is a runtime event not a mod specific configuration event. So you need Bus.FORGE The easy way to check which bus you need is whether the event implements IModBusEvent It is also a client side event (it is graphics stuff), so you also need value = Dist.CLIENT otherwise your mod will likely crash when loaded on a server. Edited July 29, 20223 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
July 29, 20223 yr You should use a IIngameOverlay, register it in FMLClientSetupEvent with one of the register methods in OverlayRegistry. You can take a look at ForgeIngameGui for the vanilla Overlays.
July 30, 20223 yr Author I used the forge bus and now it works, thanks a lot. If somebody needs it: @Mod.EventBusSubscriber(modid = MYMOD.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class CustomEvents implements IModBusEvent { static Minecraft mc = Minecraft.getInstance(); private static final ResourceLocation IMG_LOCATION = new ResourceLocation(MYMOD.MOD_ID,"textures/scream/img.png"); protected static int screenWidth; protected static int screenHeight; @SubscribeEvent public static void RenderEvent(RenderGameOverlayEvent.Post event) { Player player = Minecraft.getInstance().player; //Options settings = Minecraft.getInstance().options; screenWidth = mc.getWindow().getGuiScaledWidth(); screenHeight = mc.getWindow().getGuiScaledHeight(); assert player != null; if (player.hasEffect(MobEffects.GLOWING)) { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1F); RenderSystem.setShaderTexture(0, IMG_LOCATION); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tesselator.getBuilder(); bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); bufferbuilder.vertex(0.0D, screenHeight, -90.0D).uv(0.0F, 1.0F).endVertex(); bufferbuilder.vertex(screenWidth, (double) screenHeight, -90.0D).uv(1.0F, 1.0F).endVertex(); bufferbuilder.vertex(screenWidth, 0.0D, -90.0D).uv(1.0F, 0.0F).endVertex(); bufferbuilder.vertex(0.0D, 0.0D, -90.0D).uv(0.0F, 0.0F).endVertex(); tesselator.end(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.setShaderColor(0.0F, 0.0F, 1.0F, 1.0F); } }}
August 1, 20223 yr Author On 7/31/2022 at 5:01 AM, diesieben07 said: Please do this. This makes no sense. Sorry I'm kinda new on this. I've deleted the implementation. Also I added this: private void clientSetup(final FMLClientSetupEvent event) { OverlayRegistry.registerOverlayTop("custom_effect", (gui, poseStack, partialTick, screenWidth, screenHeight) -> { gui.setupOverlayRenderState(true, false); }); Not sure if it's fine, but it works. Now I have to discover how to show an animation using this.
August 2, 20223 yr Inside the IIngameOverlay (which you implemented in a lambda expression) you need to render the Overlay. Basically you can do the same things as you done it in RenderGameOverlayEvent.Post.
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.