[Forge, 1.5.2] Nakroma's Minecraft Modding Tutorials

Hier könnt ihr Tutorials posten!
Benutzeravatar
Nakroma
Spender
Beiträge: 39
Registriert: Fr Apr 26, 2013 2:51 pm

Re: [Forge, 1.5.2] Nakroma's Minecraft Modding Tutorials

Beitragvon Nakroma » Mi Mai 29, 2013 3:43 pm

Werd jetzt nur noch etwas erweiterte Sachen posten, hauptsächlich Sachen die ich nicht erkläre sondern einfach nur den Code zeigen.
Copy & Pasten könnt Ihr vergessen, ein bisschen müsst Ihr Java/MCP coden verstehen, oder überhaupt was mit Programmiersprachen sonst klappt das nicht.
Sinn ist deswegen, weil es die Anfängertutorials sehr zahlreich bereits im Netz gibt und ich nicht Lust habe das Rad neu zu erfinden.
Wenn Ihr Fragen habt, bezüglich was was tatsächlich macht, einfach PN oder hier im Thread.
Mfg
Zuletzt geändert von Nakroma am Mi Mai 29, 2013 3:51 pm, insgesamt 1-mal geändert.

Benutzeravatar
Nakroma
Spender
Beiträge: 39
Registriert: Fr Apr 26, 2013 2:51 pm

Re: [Forge, 1.5.2] Nakroma's Minecraft Modding Tutorials

Beitragvon Nakroma » Mi Mai 29, 2013 3:50 pm

6. Eigenes Buch
Achtung, der Code ist ziemlich wahrscheinlich nicht sauber.
Ihr müsst ein normales Item erstellen und dann mit onItemRightClick (benötigt GuiHandler btw.) eine GUI ausführen lassen, hier die GuiQuire.

Code: Alles auswählen

package nakroma.farrier;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;

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

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiQuire extends GuiScreen
{
    /** The player editing the book */
    private final EntityPlayer editingPlayer;

    /** Update ticks since the gui was opened */
    private int updateCount;
    private int bookImageWidth = 192;
    private int bookImageHeight = 192;
    private int bookTotalPages = 2;
    private int currPage;
    private int aPage = 0;
    private NBTTagList bookPages;
    private String bookTitle = "";
    private GuiQuireNextPage buttonNextPage;
    private GuiQuireNextPage buttonPreviousPage;
    private GuiButton buttonDone;


    public GuiQuire(EntityPlayer par1EntityPlayer)
    {
        this.editingPlayer = par1EntityPlayer;
    }

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

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        this.buttonList.clear();
        Keyboard.enableRepeatEvents(true);
        this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, StatCollector.translateToLocal("gui.done")));

        int i = (this.width - this.bookImageWidth) / 2;
        byte b0 = 2;
        this.buttonList.add(this.buttonNextPage = new GuiQuireNextPage(1, i + 120, b0 + 154, true));
        this.buttonList.add(this.buttonPreviousPage = new GuiQuireNextPage(2, i + 38, b0 + 154, false));
    }

    /**
     * Called when the screen is unloaded. Used to disable keyboard repeat events
     */
    public void onGuiClosed()
    {
        Keyboard.enableRepeatEvents(false);
    }

    /**
     * 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 == 0)
            {
                this.mc.displayGuiScreen((GuiScreen)null);
               // this.sendBookToServer(false);
            }
            else if (par1GuiButton.id == 1)
            {
                if (this.currPage < this.bookTotalPages - 1)
                {
                    ++this.currPage;
                    ++this.aPage;
                }
            }
            else if (par1GuiButton.id == 2)
            {
                if (this.currPage > 0)
                {
                    --this.currPage;
                    --this.aPage;
                }
            }
            //this.updateButtons();
        }
    }


    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int par1, int par2, float par3)
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture("/mods/Farrier/textures/gui/Quire.png");
        int k = (this.width - this.bookImageWidth) / 2;
        byte b0 = 2;
        this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, this.bookImageHeight);
        String s;
        String s1;
        int l;
/**
            s = String.format(StatCollector.translateToLocal("book.pageIndicator"), new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)});
            s1 = "";

            if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
            {
                NBTTagString nbttagstring = (NBTTagString)this.bookPages.tagAt(this.currPage);
                s1 = nbttagstring.toString();
            }**/

            //s1 = s1 + "" + EnumChatFormatting.GRAY + "_";
        if (aPage == 0){//Beispiel für eine Seite mit nur Text
           s = EnumChatFormatting.BOLD + "The Ancient Quire";
           s1 = "In this ancient dwarf book you will find all your recipes you've learned. You can look up descriptions and recipes again if you want to. Also all informations you collected will be stored here.";

            l = this.fontRenderer.getStringWidth(s);
            this.fontRenderer.drawString(s, k - l + this.bookImageWidth - 44, b0 + 16, 0);
            this.fontRenderer.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0);
        }
        if (aPage == 1){//Beispiel für eine Seite mit einer anderen Grafik
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.renderEngine.bindTexture("/mods/Farrier/textures/gui/Quire1.png");
            k = (this.width - this.bookImageWidth) / 2;
            b0 = 2;
            this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, this.bookImageHeight);
           
           s = EnumChatFormatting.BOLD + "Dwarven Forge";
           s1 = "The Dwarven Forge is the main tool to create stuff that you researched.";

            l = this.fontRenderer.getStringWidth(s);
            this.fontRenderer.drawString(s, k - l + this.bookImageWidth - 44, b0 + 16, 0);
            this.fontRenderer.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0);
        }
        super.drawScreen(par1, par2, par3);
    }
}


GuiQuireNextPage:

Code: Alles auswählen

package nakroma.farrier;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiQuireNextPage extends GuiButton
{
    /**
     * True for pointing right (next page), false for pointing left (previous page).
     */
    private final boolean nextPage;

    public GuiQuireNextPage(int par1, int par2, int par3, boolean par4)
    {
        super(par1, par2, par3, 23, 13, "");
        this.nextPage = par4;
    }

    /**
     * Draws this button to the screen.
     */
    public void drawButton(Minecraft par1Minecraft, int par2, int par3)
    {
        if (this.drawButton)
        {
            boolean flag = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            par1Minecraft.renderEngine.bindTexture("/gui/book.png");
            int k = 0;
            int l = 192;

            if (flag)
            {
                k += 23;
            }

            if (!this.nextPage)
            {
                l += 13;
            }

            this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
        }
    }
}

BlackwingDave

Re: [Forge, 1.5.2] Nakroma's Minecraft Modding Tutorials

Beitragvon BlackwingDave » Do Jun 20, 2013 8:24 pm

kommt noch was? Du hast lange nichts mehr geschrieben.

Ellillera
Neuling
Beiträge: 1
Registriert: Do Mai 09, 2019 6:58 am

Super Kamagra Nebenwirkungen EllMaps

Beitragvon Ellillera » Do Mai 30, 2019 9:39 am

Billig Cialis Zithromax Extended Release Canadianhealthandcaremallviagra where to buy cialis online safely Actualite Propecia Priligy Plus Viagra
Amoxicilline Est Priligy Et Cialis Together Comprare Viagra Line cheap cialis Viagra 50mg


Zurück zu „Knowledge“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast