[1.6.4]Замена стандартного GUI опций

Вообщем проблема такова.
Создаю в прокси EVENT_BUS 
Код:
MinecraftForge.EVENT_BUS.register(new FakeOptionEvent());
Там происходит следующее - 
Код:
public class FakeOptionEvent extends Event {
    @ForgeSubscribe
    @SideOnly(Side.CLIENT)
    public void GuiVanillaChanger(GuiOpenEvent event) {
        
        if(event.gui instanceof GuiOptions) {
            event.gui = new GuiFakeOption();
            System.out.println("FAKE MENU OPEN");
            
        }
    }
}
Эклипс подчеркивает GuiFakeOption, если создаю ему аргументы, кидает на null.
А еще пишет типа "Добавьте аргументы "GuiScreen, GameSettings""
Вооот.Код теперь таков - 
Код:
public class FakeOptionEvent extends Event {
    private GuiScreen parentScreen;
    private GameSettings options;
    @ForgeSubscribe
    @SideOnly(Side.CLIENT)
    public void GuiVanillaChanger(GuiOpenEvent event) {
        
        if(event.gui instanceof GuiOptions) {
            event.gui = new GuiFakeOption(parentScreen, options);
            System.out.println("FAKE MENU OPEN");
            
        }
    }
}
Но при заходе в опции крашит.Прошу помощи, проблему решить не можем уже день наверное третий!
 
annalifegame написал(а):
Ладно, можно закрывать, все равно наверное никто не поможет...
Он наверное имел ввиду, что нужно создать обьект а не переменную!?
 
Потому что анна вообще не знает, как работают эвенты.
Во-первых, наследовать Event нужно только когда у вас свой эвент, а это - хэндлер эвентов.
Во-вторых, методы с маленькой буквы.
В-третьих, ты передаешь в конструктор параметры, которые равны null.
В-четвертых, parentScreen'ом будет GuiMainMenu, а gameSettings можно достать через Minecraft.getMinecraft().gameSettings.
 
Короче, доперло.
Пользуйтесь - 
Код:
package test;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiOptions;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.event.Event;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class FakeOptionEvent extends Event {
    private GuiScreen guiScreen;
    public GameSettings optionsMainCraft = Minecraft.getMinecraft().gameSettings;
    @ForgeSubscribe
    @SideOnly(Side.CLIENT)
    public void GuiVanillaChanger(GuiOpenEvent event) {
        if(event.gui instanceof GuiOptions) {
            event.gui = new GuiFakeOption(guiScreen, optionsMainCraft);
            System.out.println("FAKE OPTION OPEN");  
        }
    }
}

Код:
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiControls;
import net.minecraft.client.gui.GuiLanguage;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSlider;
import net.minecraft.client.gui.GuiSmallButton;
import net.minecraft.client.gui.GuiSnooper;
import net.minecraft.client.gui.GuiVideoSettings;
import net.minecraft.client.gui.ScreenChatOptions;
import net.minecraft.client.resources.GuiScreenTemporaryResourcePackSelect;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.EnumOptions;
import net.minecraft.client.settings.GameSettings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiFakeOption extends GuiScreen
{
    /**
     * An array of options that can be changed directly from the options GUI.
     */
    private static final EnumOptions[] relevantOptions = new EnumOptions[] {EnumOptions.MUSIC, EnumOptions.SOUND , EnumOptions.SENSITIVITY, EnumOptions.FOV, EnumOptions.TOUCHSCREEN};

    /**
     * A reference to the screen object that created this. Used for navigating between screens.
     */
    private final GuiScreen parentScreen;

    /** Reference to the GameSettings object. */
    private final GameSettings options;

    /** The title string that is displayed in the top-center of the screen. */
    protected String screenTitle = "Options";

    public GuiFakeOption(GuiScreen par1GuiScreen, GameSettings par2GameSettings)
    {
        this.parentScreen = par1GuiScreen;
        this.options = par2GameSettings;
    }

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        int i = 0;
        EnumOptions[] aenumoptions = relevantOptions;
        int j = aenumoptions.length;

        for (int k = 0; k < j; ++k)
        {
            EnumOptions enumoptions = aenumoptions[k];

            if (enumoptions.getEnumFloat())
            {
                this.buttonList.add(new GuiSlider(enumoptions.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), enumoptions, this.options.getKeyBinding(enumoptions), this.options.getOptionFloatValue(enumoptions)));
            }
            else
            {
                GuiSmallButton guismallbutton = new GuiSmallButton(enumoptions.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), enumoptions, this.options.getKeyBinding(enumoptions));
/*
                if (enumoptions == EnumOptions.DIFFICULTY && this.mc.theWorld != null && this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
                {
                    guismallbutton.enabled = false;
                    guismallbutton.displayString = I18n.getString("options.difficulty") + ": " + I18n.getString("options.difficulty.hardcore");
                }
*/
                this.buttonList.add(guismallbutton);
            }

            ++i;
        }

        this.buttonList.add(new GuiButton(101, this.width / 2 - 75, this.height / 6 + 96 - 6, 150, 20, I18n.getString("options.video")));
        this.buttonList.add(new GuiButton(100, this.width / 2 - 75, this.height / 6 + 135 - 6, 150, 20, I18n.getString("options.controls")));
       // this.buttonList.add(new GuiButton(102, this.width / 2 - 152, this.height / 6 + 120 - 6, 150, 20, I18n.getString("options.language")));
        this.buttonList.add(new GuiButton(103, this.width / 2 - 75, this.height / 6 + 116 - 6, 150, 20, I18n.getString("options.multiplayer.title")));
        //this.buttonList.add(new GuiButton(105, this.width / 2 - 152, this.height / 6 + 144 - 6, 150, 20, I18n.getString("options.resourcepack")));
        //this.buttonList.add(new GuiButton(104, this.width / 2 + 2, this.height / 6 + 144 - 6, 150, 20, I18n.getString("options.snooper.view")));
        this.buttonList.add(new GuiButton(200, this.width / 2 - 75, this.height / 6 + 168, 150, 20, I18n.getString("gui.done")));
    }

    /**
     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
     */
    protected void actionPerformed(GuiButton par1GuiButton)
    {
        if (par1GuiButton.enabled)
        {
            if (par1GuiButton.id < 100 && par1GuiButton instanceof GuiSmallButton)
            {
                this.options.setOptionValue(((GuiSmallButton)par1GuiButton).returnEnumOptions(), 1);
                par1GuiButton.displayString = this.options.getKeyBinding(EnumOptions.getEnumOptions(par1GuiButton.id));
            }

            if (par1GuiButton.id == 101)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new GuiVideoSettings(this, this.options));
            }

            if (par1GuiButton.id == 100)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new GuiControls(this, this.options));
            }

            if (par1GuiButton.id == 102)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new GuiLanguage(this, this.options, this.mc.getLanguageManager()));
            }

            if (par1GuiButton.id == 103)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new ScreenChatOptions(this, this.options));
            }

            if (par1GuiButton.id == 104)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new GuiSnooper(this, this.options));
            }

            if (par1GuiButton.id == 200)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(this.parentScreen);
            }

            if (par1GuiButton.id == 105)
            {
                this.mc.gameSettings.saveOptions();
                this.mc.displayGuiScreen(new GuiScreenTemporaryResourcePackSelect(this, this.options));
            }
        }
    }

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int par1, int par2, float par3)
    {
        this.drawDefaultBackground();
        this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 15, 16777215);
        super.drawScreen(par1, par2, par3);
    }
}
Изменяйте что как надо..
 
Вообще кыш, если не умеешь работать с эвентами. Я тебе пояснил в предыдущем посте, что необходимо заменить и подправить в коде. Ты же на это никак не отреагировала.
 
Dragon2488 написал(а):
Вообще кыш, если не умеешь работать с эвентами. Я тебе пояснил в предыдущем посте, что необходимо заменить и подправить в коде. Ты же на это никак не отреагировала.
Код работает, и работает ПРАВИЛЬНО, а остальное не волнует!
 
А на экзаменах скажешь
Текст написан правильно и кыш.
А проверка поклацает работы за кривизну почерка
 
Назад
Сверху