Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello everyone, I'm facing the problem that my texture is not displayed in minecraft. I made a mod so that a dialog box appeared, when I did it, I just had to add my texture to the background, but when I started minecraft, I ran into a problem that minecraft does not see my texture. I do not understand what the problem is, if the error is some kind of stupid, then forgive me, I'm just not strong in programming. Help me please.
Screen: https://prnt.sc/RMYDi-gkKG1-

  • Author
1 hour ago, MoonManich said:

Hello everyone, I'm facing the problem that my texture is not displayed in minecraft. I made a mod so that a dialog box appeared, when I did it, I just had to add my texture to the background, but when I started minecraft, I ran into a problem that minecraft does not see my texture. I do not understand what the problem is, if the error is some kind of stupid, then forgive me, I'm just not strong in programming. Help me please.
Screen: https://prnt.sc/RMYDi-gkKG1-

My code: 

package com.example.examplemod;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.inventory.InventoryScreen;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;

import java.nio.charset.StandardCharsets;

public class CustomGui extends Screen {
private String option1Text = new String("Как мы тут оказались?".getBytes(), StandardCharsets.UTF_8);
private String option2Text = new String("Что за лаборатория ФьючерТек".getBytes(), StandardCharsets.UTF_8);
private String option3Text = new String("Какой сейчас год?".getBytes(), StandardCharsets.UTF_8);

public CustomGui() {
super(new StringTextComponent("Custom Menu"));


}

private static final ResourceLocation background = new ResourceLocation("custommenu", "textures/gui/background.png");

@Override
protected void init() {
super.init();
}

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
renderBackground(matrixStack);

// Draw the background texture
Minecraft.getInstance().getTextureManager().bind(background);

int backgroundWidth = 200;
int backgroundHeight = 100;

int xOffset = (width - backgroundWidth) / 2;
int yOffset = (height - backgroundHeight) / 2;

// Prevent the background texture from repeating
blit(matrixStack, 0, 0, backgroundWidth, backgroundHeight, backgroundWidth, backgroundHeight);

// int barHeight = 130;
// int margin = 70;
// fill(matrixStack, 0, height - barHeight - margin, width, height - margin, 0x80000000);

int textWidth = font.width(option1Text);
int textHeight = font.lineHeight;
int textSpacing = 2;

drawCenteredString(matrixStack, font, new String("Они только очнулись, подожди..".getBytes(), StandardCharsets.UTF_8), width / 2, height / 2 - 50, 0xff00ff00); // Зеленый текст

drawString(matrixStack, font, option1Text, width / 2 - textWidth / 2, height / 2 - textHeight - textSpacing, isMouseOverOption(mouseX,mouseY,1)?0xffffff00:0xff00ff00);
drawString(matrixStack, font, option2Text,width/2-textWidth/2,height/2,isMouseOverOption(mouseX,mouseY,2)?0xffffff00:0xff00ff00);
drawString(matrixStack, font, option3Text,width/2-textWidth/2,height/2+textHeight+textSpacing,isMouseOverOption(mouseX,mouseY,3)?0xffffff00:0xff00ff00);

// Отображение персонажа игрока справа
LivingEntity player = Minecraft.getInstance().player;
int size = (int) (height * .15); // Уменьшение размера персонажа
InventoryScreen.renderEntityInInventory(width - (width / 4), height / 2 + (height / 4), size,(float)(width-(width/4))-mouseX,(float)(height/2+(height/4))-mouseY-50 , player);

// Обрезание ног персонажа
fill(matrixStack,width-(width/4)-size/2,height/2+(height/4),width-(width/4)+size/2,height,size==64?0xff000000:0);
}

private boolean isMouseOverOption(double mouseX,double mouseY,int option){
int textWidth=font.width(option1Text);
int textHeight=font.lineHeight;
int textSpacing=2;

if(mouseX>=width/2-textWidth/2&&mouseX<=width/2+textWidth/2){
if(option==1&&mouseY>=height/2-textHeight-textSpacing&&mouseY<=height/2-textSpacing){
return true;
}else if(option==2&&mouseY>=height/2&&mouseY<=height/2+textHeight){
return true;
}else if(option==3&&mouseY>=height/2+textHeight+textSpacing&&mouseY<=height/2+textHeight*2+textSpacing){
return true;
}
}

return false;
}

@Override
public boolean mouseClicked(double mouseX,double mouseY,int button){
int textWidth=font.width(option1Text);
int textHeight=font.lineHeight;
int textSpacing=2;

if(mouseX>=width/2-textWidth/2&&mouseX<=width/2+textWidth/2){
if(mouseY>=height/2-textHeight-textSpacing&&mouseY<=height/2-textSpacing){
// Действия при выборе варианта "Stop it,it's annoying"
Minecraft.getInstance().setScreen(null);
return true;
}else if(mouseY>=height/2&&mouseY<=height/2+textHeight){
// Действия при выборе варианта "Behave as if you're my boss"
Minecraft.getInstance().setScreen(null);
return true;
}else if(mouseY>=height/2+textHeight+textSpacing&&mouseY<=height/2+textHeight*2+textSpacing){
// Действия при выборе варианта "You should show more respect than just poking"
Minecraft.getInstance().setScreen(null);
return true;
}
}

return super.mouseClicked(mouseX,mouseY,button);
}

@Override
public boolean isPauseScreen() {
return false;
}
}

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.