GUI

Версия Minecraft
1.12.2
89
2
Java:
package ru.theklimot.npc.gui;

import java.io.IOException;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import ru.theklimot.npc.Main;

public class SkolGui extends GuiScreen {
     private final int guiHeight = 120;
     private final int guiWidth = 256;
     private static ResourceLocation guiTexture;
    public static Object instance;

public SkolGui() {
    guiTexture = new ResourceLocation(Main.MODID+ ":textures/gui/skolgui.png");
}
private String formatString(String s) {
    return s.replace("NL", "\n\n");
}
@Override
public void initGui() {
    Keyboard.enableRepeatEvents(true);
}
@Override
public void updateScreen() {
    super.updateScreen();
}
@Override
public void drawScreen(int w, int h, float p_73863_3_) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.getTextureManager().bindTexture(guiTexture);
    int offsetFromScreenLeft = (width - guiWidth) / 2;
    fontRenderer.drawString("БУДЬТЕ ОСТОРОЖНЫ!", offsetFromScreenLeft + guiWidth - 50, 170, 0);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
}
public void onGuiClose() {
    Keyboard.enableRepeatEvents(false);
}
@Override
public boolean doesGuiPauseGame() {
    return false;
}
}


Java:
package ru.theklimot.npc.gui;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.registry.EntityEntry;
import ru.theklimot.npc.mobs.EntityRegistry;
import ru.theklimot.npc.mobs.EntitySmallHerobrine;
import scala.reflect.internal.Trees.New;

public class OpenGuiMobs extends EntityRegistry {
     public void opengui(PlayerInteractEvent.EntityInteract event) {
         Entity entity = event.getEntity();
         EntityPlayer p = event.getEntityPlayer();
         if (entity instanceof EntityLivingBase) {
             return;
         }
     }
     }
В гуи почти не шарю, нужна помощь, как теперь мобу привязать открытие? Ivasik помог, но я не совсем понял.
 
Решение
Ты NPS делаешь чтоль?
Подозреваю что во тут
Java:
public class OpenGuiMobs extends EntityRegistry {
     public void opengui(PlayerInteractEvent.EntityInteract event) {
         Entity entity = event.getEntity();
         EntityPlayer p = event.getEntityPlayer();
         if (entity instanceof EntityLivingBase) {
             return;
         }
     }
     }

Имеет место быть

Java:
if (!world.isRemote) {
            FMLCommonHandler.instance().showGuiScreen(new SkolGui());
89
2
Java:
package ru.theklimot.npc.mobs;


import net.minecraft.client.renderer.entity.RenderEntity;

import net.minecraftforge.event.RegistryEvent;

import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import net.minecraftforge.fml.common.registry.EntityEntry;

import net.minecraftforge.fml.common.registry.EntityEntryBuilder;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import ru.theklimot.npc.*;

import ru.theklimot.npc.gui.OpenGuiMobs;


@Mod.EventBusSubscriber(modid = Main.MODID)

public class EntityRegistry {


    @SideOnly(Side.CLIENT)//

    public static void initModels() {

        /**/

        RenderingRegistry.registerEntityRenderingHandler(EntitySmallHerobrine.class, RenderEntityHerobrine.FACTORY);

    }


    private static int ID = 0;


    public static EntityEntry SMALL_HEROBRINE = EntityEntryBuilder

            .create()

            .entity(EntitySmallHerobrine.class)

            .name("Small Herobrine")//   

            .id("small_herobrine", ID++)

            .egg(0xff4040, 0xd891ef)

            .tracker(160, 2, false)

            .build();

          


    @SubscribeEvent

    public static void registryEntity(RegistryEvent.Register<EntityEntry> event) {


        event.getRegistry().registerAll(

                SMALL_HEROBRINE

        );

    }

}
Регистр моба.
 
77
3
8
Ты NPS делаешь чтоль?
Подозреваю что во тут
Java:
public class OpenGuiMobs extends EntityRegistry {
     public void opengui(PlayerInteractEvent.EntityInteract event) {
         Entity entity = event.getEntity();
         EntityPlayer p = event.getEntityPlayer();
         if (entity instanceof EntityLivingBase) {
             return;
         }
     }
     }

Имеет место быть

Java:
if (!world.isRemote) {
            FMLCommonHandler.instance().showGuiScreen(new SkolGui());
 
89
2
Ты NPS делаешь чтоль?
Подозреваю что во тут
Java:
public class OpenGuiMobs extends EntityRegistry {
     public void opengui(PlayerInteractEvent.EntityInteract event) {
         Entity entity = event.getEntity();
         EntityPlayer p = event.getEntityPlayer();
         if (entity instanceof EntityLivingBase) {
             return;
         }
     }
     }

Имеет место быть

Java:
if (!world.isRemote) {
            FMLCommonHandler.instance().showGuiScreen(new SkolGui());
Та я сам починил и у меня работает эта гуишка, только с кнопкой проблема)
 

Вложения

  • Снимок22.PNG
    Снимок22.PNG
    294.6 KB · Просмотры: 25
  • Снимок333.PNG
    Снимок333.PNG
    67.8 KB · Просмотры: 26
89
2
Java:
    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        drawDefaultBackground();
        Minecraft.getMinecraft().renderEngine.bindTexture(texture);
        int centerX = (width / 2) - guiWidth / 2;
        int centerY = (height / 2) - guiHeight / 2;
        //drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);
        //drawString(fontRendererObj, "Tutorial", centerX, centerY, 0x6028ff);
        GlStateManager.pushMatrix();
        {
            GlStateManager.enableAlpha();
            GlStateManager.enableBlend();
            GlStateManager.color(1, 1, 1, 1);
            Minecraft.getMinecraft().renderEngine.bindTexture(texture);
            drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);
        }
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        {
            GlStateManager.translate((width / 2) - fontRenderer.getStringWidth(title), centerY + 10, 0);
            GlStateManager.scale(2, 2, 2);
            fontRenderer.drawString(title, 0, 0, 0x6028ff);
        }
        GlStateManager.popMatrix();
        //super.drawScreen(mouseX, mouseY, partialTicks);
        button1.drawButton(mc, mouseX, mouseY, partialTicks);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        {
            GlStateManager.translate((width / 2) - fontRenderer.getStringWidth(title), centerY + 10, 0);
            GlStateManager.scale(2, 2, 2);
        }
        GlStateManager.popMatrix();
        List<String> text = new ArrayList<String>();
        drawTooltip(text, mouseX, mouseY, centerX, centerY, 16 * 2, 16 * 2);
    }

    public void drawTooltip(List<String> lines, int mouseX, int mouseY, int posX, int posY, int width, int height) {
        if (mouseX >= posX && mouseX <= posX + width && mouseY >= posY && mouseY <= posY + height) {
            drawHoveringText(lines, mouseX, mouseY);
        }
    }

    @Override
    public void initGui() {
        buttonList.clear();
        buttonList.add(button1 = new GuiButton(BUTTON1, (width / 2) - 100 / 2, height - 40, 100, 20, "Close")); 
        updateButtons();
        super.initGui();
    }
 
77
3
8
Думаю это тебе поможет ТЫК

Типо маштабируй по обоим плоскостям от разрешения экрана, и она не будет убегать
buttonList.add(button1 = new GuiButton(BUTTON1, (width / 2) - 100 / 2, height - 40, 100, 20, "Close"));

У тебя высота не имеет привязки к центру, вот и бегает
 
Сверху