Posted November 28, 20204 yr Hi I would like to know how could I render an overlay (like pumpkin) once player have a certain armor piece on him.
November 28, 20204 yr Subscribe to the RenderGameOverlayEvent and check if the player is wearing the armor piece you want. The IngameGui class is a good source of informations, there you can find how vanilla renders the pumpkin overlay Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
November 28, 20204 yr Author OK so using RenderGameOverlayEvent I managed to check when the player have a certain item on the helmet slot but fore some reason the overlay itself don't work. Here is the code: public class MODIngameGui extends IngameGui { protected static final ResourceLocation GASMASK_BLUR_TEX_PATH = new ResourceLocation("mod:textures/guis/gasmask.png"); protected void renderGasmaskOverlay() { RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.defaultBlendFunc(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableAlphaTest(); this.mc.getTextureManager().bindTexture(GASMASK_BLUR_TEX_PATH); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos(0.0D, (double)this.scaledHeight, -90.0D).tex(0.0F, 1.0F).endVertex(); bufferbuilder.pos((double)this.scaledWidth, (double)this.scaledHeight, -90.0D).tex(1.0F, 1.0F).endVertex(); bufferbuilder.pos((double)this.scaledWidth, 0.0D, -90.0D).tex(1.0F, 0.0F).endVertex(); bufferbuilder.pos(0.0D, 0.0D, -90.0D).tex(0.0F, 0.0F).endVertex(); tessellator.draw(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); } public MODIngameGui(Minecraft mcIn, MatrixStack matrixStack) { super(mcIn); ItemStack itemstack = this.mc.player.inventory.armorItemInSlot(3); if (this.mc.gameSettings.getPointOfView().func_243192_a() && itemstack.getItem() == items_MOD.GAS_MASK.get()) { this.renderGasmaskOverlay(); mod.LOGGER.info("test test test"); } } } even tried to use, renderPumpkinOverlay but no success the message appear in the console by the way Edited November 28, 20204 yr by Grandlovania
November 28, 20204 yr Author @Mod.EventBusSubscriber public class MODClientEvents { @SubscribeEvent public static void RenderModOverlay(RenderGameOverlayEvent.Post event) { new MODIngameGui(Minecraft.getInstance(), event.getMatrixStack()); } }
November 28, 20204 yr 3 hours ago, Grandlovania said: Hi I would like to know how could I render an overlay (like pumpkin) once player have a certain armor piece on him. If it is your own custom item, you could use the renderHelmetOverlay() method instead of an event.
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.