Posted December 7, 20213 yr [1.17]Hey bro,i want to load a texture that can appear on the screen(like ui) when i hold some itmes,so i make a: package com.xiaomi.derby.screen; import com.mojang.blaze3d.vertex.PoseStack; import com.xiaomi.derby.item.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import static net.minecraftforge.fmlclient.gui.GuiUtils.drawTexturedModalRect; public class UIRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation("derby","textures/gui/speed_bar"); @SubscribeEvent public void onRenderGui(RenderGameOverlayEvent.Post event) { LocalPlayer player = Minecraft.getInstance().player; if(RenderGameOverlayEvent.ElementType.ALL.equals(event.getType())){ assert player != null; if(player.getItemInHand(InteractionHand.MAIN_HAND).is(ModItems.HORSE_WHIP.get())) { Minecraft.getInstance().textureManager.bindForSetup(TEXTURE); drawTexturedModalRect(new PoseStack(), 50, 50, 80, 41, 80, 41, 0); } } } } But when i entered the game , i found there was not the texture which i set,it was a black rectangle.Can you tell me how can i solve this problem?THANKS A LOT!
December 8, 20213 yr Author 19 hours ago, diesieben07 said: Use OverlayRegistry in 1.17 and later. Thanks,but could you tell me what should accurately do to modify the codes to achieve my goal?
December 8, 20213 yr Author 8 minutes ago, diesieben07 said: What? I mean what should i do to use the OverlayRegistry to draw the texture in my screen(in the game). Edited December 8, 20213 yr by xiaomi_lai
December 8, 20213 yr Author 53 minutes ago, diesieben07 said: OverlayRegistry has extensive Javadocs. It should be quite obvious how to use it. Okay i will try it,thank you
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.