[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!