Jump to content

[1.17]Texture's load problems


xiaomi_lai

Recommended Posts

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

 

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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