Home > OS >  Minecraft cannot put custom background
Minecraft cannot put custom background

Time:11-21

I am making a custom minecraft client. For it i want to make a custom main menu, i try the code:

@Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        // draw a image
        mc.getTextureManager().bindTexture(new ResourceLocation("moon/gui/background.jpg"));
        this.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, this.width, this.height, this.width, this.height);
        super.drawScreen(mouseX,mouseY,partialTicks);
    }

And then replace GuiMainMenu(which is the default Minecraft main menu class) with CustomMainMenu(which is my Main Menu Class) I then try to run it, and it results in 2 pink and black boxes which mean the background file which is bg.jpg was not found. This is confirmed by the console output which says java.io file not found. I wanted it to show my background image but it did not.

A few things I tried:

  • Re-downloading java
  • Changing the background image
  • changing the background image package from MOON.gui to moon.gui and moon and back to moon.gui
  • Asking for help in a Minecraft client making File Structure

    CodePudding user response:

    You said "the file is not found". This can be caused by multiple things :

    • File not in plugin (Seems to be your case)

    How to fix:

    You should check that they are in good package. In your case, they should be on src/resources, but you wrote them somewhere else. So, move it to src/resources/moon/gui/bg.jpg

    • Not exported in runned jar

    How to fix:

    It depend of what your are using between maven/gradle/something else, and with their config. But by default, all content of src/resources is included in jar.

    • Not enough permission to read file

    How to fix:

    You have to check why you don't have permission, and add "read" perm. On linux for example it's with chmod command.

  • Related