- 201
- 6
- 32
Заменил своё меню.
При нажатии на кнопку, должно заходить на сервер.
Нажимаю на кнопку, и вылазит ошибка NPE, игра при этом не крашится.
Вот код МЕНЮ
В консоли если заходить в eclipse
При нажатии на кнопку, должно заходить на сервер.
Нажимаю на кнопку, и вылазит ошибка NPE, игра при этом не крашится.
Вот код МЕНЮ
Java:
package ru.FuxKlin.NClientFixed.gui;
import java.awt.Desktop;
import java.net.URL;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiOptions;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSelectWorld;
import net.minecraft.client.multiplayer.GuiConnecting;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import ru.FuxKlin.NClientFixed.NClientFixed;
public class NMainMenu extends GuiMainMenu
{
int btnSelected = 0;
public int MX = 0;
public int MY = 0;
int lastId = 0;
public static String URL_SITE = "https://vk.com/";
public String URL_DONATE = "https://vk.com/";
protected boolean isClicked = false;
public static final ResourceLocation textureback = new ResourceLocation(NClientFixed.MODID + ":textures/gui/nbackscreen.png");
@Override
public void initGui() {
int i = this.width / 2 - 450;
this.buttonList.clear();
this.buttonList.add(new GuiButton(1001, i + this.height / 4 + 48, + 60 + 12, 145, 20, I18n.format("Вход на сервер", new Object[0])));
this.buttonList.add(new GuiButton(1002, i + this.height / 4 + 48, + 94 + 12, 145, 20, I18n.format("Личный Кабинет", new Object[0])));
this.buttonList.add(new GuiButton(1003, i + this.height / 4 + 48, + 128 + 12, 145, 20, I18n.format("Группа ВК", new Object[0])));
this.buttonList.add(new GuiButton(1004, i + this.height / 4 + 48, + 162 + 12, 145, 20, I18n.format("Настройки", new Object[0])));
this.buttonList.add(new GuiButton(1005, i + this.height / 4 + 48, + 196 + 12, 145, 20, I18n.format("Закрыть игру", new Object[0])));
}
@Override
public void actionPerformed(GuiButton btn)
{
if (btn.id == 1001)
{
this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, new ServerData("N Craft", "(IP палить не буду)", isClicked)));
//this.mc.displayGuiScreen(new GuiSelectWorld(this));
}
switch(btn.id)
{
case 1002:
try
{
Desktop.getDesktop().browse((new URL(URL_SITE)).toURI());
}
catch (Exception var5)
{
var5.printStackTrace();
}
break;
case 1003:
try
{
Desktop.getDesktop().browse((new URL(URL_DONATE)).toURI());
}
catch (Exception var6) {
var6.printStackTrace();
}
break;
}
if (btn.id == 1004)
{
this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
}
if (btn.id == 1005)
{
this.mc.shutdown();
}
}
@Override
public void drawScreen(int x, int y, float t) {
this.MX = x;
this.MY = y;
super.mc.renderEngine.bindTexture(textureback);
this.drawCompleteImage(0, 0, this.width, this.height);
int k1;
for (k1 = 0; k1 < this.buttonList.size(); ++k1)
((GuiButton)this.buttonList.get(k1)).drawButton(this.mc, x, y);
}
boolean isHover(int xx, int yy, int xx1, int yy1) {
return isClicked;
}
public void drawCompleteImage(int posX, int posY, int width, int height) {
GL11.glPushMatrix();
GL11.glTranslatef((float)posX, (float)posY, 0.0F);
GL11.glBegin(7);
GL11.glTexCoord2f(0.0F, 0.0F);
GL11.glVertex3f(0.0F, 0.0F, 0.0F);
GL11.glTexCoord2f(0.0F, 1.0F);
GL11.glVertex3f(0.0F, (float)height, 0.0F);
GL11.glTexCoord2f(1.0F, 1.0F);
GL11.glVertex3f((float)width, (float)height, 0.0F);
GL11.glTexCoord2f(1.0F, 0.0F);
GL11.glVertex3f((float)width, 0.0F, 0.0F);
GL11.glEnd();
GL11.glPopMatrix();
}
}
В консоли если заходить в eclipse
Java:
Unexpected packet during modded negotiation - assuming vanilla or keepalives : net.minecraft.network.play.server.S00PacketKeepAlive
- Краш-лог
Internal Exception: java.lang.NullPointerException
Краш-лог:
Internal Exception: java.lang.NullPointerException