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.

MoonManich

Members
  • Joined

  • Last visited

  1. 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; } }
  2. 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-
  3. When I made the mod, registered everything, and so on, I should open a menu with the choice of the answer to the H key, but when I press it in minecraft itself, it crashes, why? My main class code: package com.example.examplemod; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.lwjgl.glfw.GLFW; @Mod("custommenu") @Mod.EventBusSubscriber(Dist.CLIENT) public class custommenu { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if (event.getKey() == GLFW.GLFW_KEY_H && event.getAction() == GLFW.GLFW_PRESS) { Minecraft.getInstance().setScreen(new CustomGui()); } } } my second class where the code is written to open the menu: package com.example.examplemod; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TranslationTextComponent; import org.lwjgl.glfw.GLFW; public class CustomGui extends Screen { private final ResourceLocation background = new ResourceLocation("custommenu", "textures/gui/background.png"); private Button yesButton; private Button noButton; private Button laterButton; public CustomGui() { super(null); } @Override protected void init() { super.init(); yesButton = new Button(width / 2 - 100, height / 2 - 24, 200, 20, new TranslationTextComponent("Да"), button -> { // Действия при выборе варианта "Да" Minecraft.getInstance().setScreen(null); }); noButton = new Button(width / 2 - 100, height / 2, 200, 20, new TranslationTextComponent("Нет"), button -> { // Действия при выборе варианта "Нет" Minecraft.getInstance().setScreen(null); }); laterButton = new Button(width / 2 - 100, height / 2 + 24, 200, 20, new TranslationTextComponent("Позже"), button -> { // Действия при выборе варианта "Позже" Minecraft.getInstance().setScreen(null); }); addButton(yesButton); addButton(noButton); addButton(laterButton); } @Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { // Отображение текстуры Minecraft.getInstance().getTextureManager().bind(background); blit(matrixStack, 0, 0, 0, 0, width, height); // Отображение кнопок super.render(matrixStack, mouseX, mouseY, partialTicks); } @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_ESCAPE) { Minecraft.getInstance().setScreen(null); return true; } else if (keyCode == GLFW.GLFW_KEY_H) { // Открываем ваше меню с выбором ответа Minecraft.getInstance().setScreen(new CustomGui()); return true; } return super.keyPressed(keyCode, scanCode, modifiers); } @Override public boolean isPauseScreen() { return false; } }

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.