Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Tworzenie przycisku MCP 1.8.9


Danelow

Rekomendowane odpowiedzi

Opublikowano

Witam.
Tworzę aktualnie mało zaawansowany projekt Launchera + Clienta, który ma odpowiadać za wprowadzenie kilku estetycznych modyfikacji w Forge + służyć jako zabezpieczenie niskobudżetowego serwera dla znajomych.
Znajdują się w nim takie modyfikacje jak Keystrokes, Compass czy Dragon Wings.
Stąd moje pytanie - miałby ktoś pomysł jak stworzyć przycisk w Gui "InGameMenu" podłączony do tych 3 modyfikacji?
Już tłumaczę - guzik miałby służyć do otwarcia kolejnego gui w którym znajdowałyby się kolejne 3. Każdy z nich odpowiadałby za wejście w edytorskie możliwości modów (kolor, położenie obiektu, wielkość, etc.).
Na dany moment jedynym sposobem edycji każdego z modów są komendy typu /keystrokes.
Poniżej podstawowy kod "IngameMenu" z wersji 1.8.9 oraz kod "CommandEditStrokes":
IngameMenu:

Spoiler

package net.minecraft.client.gui;

import java.io.IOException;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.gui.achievement.GuiStats;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.realms.RealmsBridge;

public class GuiIngameMenu extends GuiScreen
{
    private int field_146445_a;
    private int field_146444_f;

    /**
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
     * window resizes, the buttonList is cleared beforehand.
     */
    public void initGui()
    {
        this.field_146445_a = 0;
        this.buttonList.clear();
        int i = -16;
        int j = 98;
        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + i, I18n.format("menu.returnToMenu", new Object[0])));

        if (!this.mc.isIntegratedServerRunning())
        {
            ((GuiButton)this.buttonList.get(0)).displayString = I18n.format("menu.disconnect", new Object[0]);
        }

        this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + i, I18n.format("menu.returnToGame", new Object[0])));
        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + i, 98, 20, I18n.format("menu.options", new Object[0])));
        GuiButton guibutton;
        this.buttonList.add(guibutton = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + i, 98, 20, I18n.format("menu.shareToLan", new Object[0])));
        this.buttonList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + i, 98, 20, I18n.format("gui.achievements", new Object[0])));
        this.buttonList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + i, 98, 20, I18n.format("gui.stats", new Object[0])));
        guibutton.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic();
    }
    
    /**
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
     */
    
    protected void actionPerformed(GuiButton button) throws IOException
    {
        switch (button.id)
        {
            case 0:
                this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
                break;

            case 1:
                boolean flag = this.mc.isIntegratedServerRunning();
                boolean flag1 = this.mc.isConnectedToRealms();
                button.enabled = false;
                this.mc.theWorld.sendQuittingDisconnectingPacket();
                this.mc.loadWorld((WorldClient)null);

                if (flag)
                {
                    this.mc.displayGuiScreen(new GuiMainMenu());
                }
                else if (flag1)
                {
                    RealmsBridge realmsbridge = new RealmsBridge();
                    realmsbridge.switchToRealms(new GuiMainMenu());
                }
                else
                {
                    this.mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu()));
                }

            case 2:
            case 3:
            default:
                break;

            case 4:
                this.mc.displayGuiScreen((GuiScreen)null);
                this.mc.setIngameFocus();
                break;

            case 5:
                this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
                break;

            case 6:
                this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
                break;

            case 7:
                this.mc.displayGuiScreen(new GuiShareToLan(this));
        }
    }

    /**
     * Called from the main game loop to update the screen.
     */
    public void updateScreen()
    {
        super.updateScreen();
        ++this.field_146444_f;
    }

    /**
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
     */
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
        this.drawDefaultBackground();
        this.drawCenteredString(this.fontRendererObj, I18n.format("menu.game", new Object[0]), this.width / 2, 40, 16777215);
        super.drawScreen(mouseX, mouseY, partialTicks);
    }
}

 



CommandEditStrokes:
 

Spoiler

package net.canelex.keystrokes;

import net.canelex.keystrokes.gui.GuiEditKeystrokes;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;

public class CommandEditStrokes extends CommandBase {
   private KeystrokesMod mod;

   public CommandEditStrokes(KeystrokesMod mod) {
      this.mod = mod;
   }

   public String func_71517_b() {
      return "keystrokes";
   }

   public String func_71518_a(ICommandSender sender) {
      return "/keystrokes";
   }

   public boolean func_71519_b(ICommandSender sender) {
      return true;
   }

   public void func_71515_b(ICommandSender sender, String[] args) {
      MinecraftForge.EVENT_BUS.register(this);
   }

   @SubscribeEvent
   public void onTick(ClientTickEvent event) {
      MinecraftForge.EVENT_BUS.unregister(this);
      Minecraft.func_71410_x().func_147108_a(new GuiEditKeystrokes(this.mod));
   }
}

 

 

Z góry dodam, że jestem czysto amatorem w sprawach programowania. Moimi jedynymi źródłami wiedzy są zagraniczne poradniki i na nich wzoruje swoje prace.
Dziękuję za pomoc! ?

Ciężko jest żyć lekko..

  • Biter. zmienił(a) tytuł na Tworzenie przycisku MCP 1.8.9

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...