Jump to content

(solved) GuiScreen Help when making a book


XxArchangelz

Recommended Posts

I'm trying to make a book like that of Thaumcraft and Mystcraft that you right-click the item and it opens a gui that I later will have a functionality such as controls for a machine receptacle. I am fairly new to modding minecraft and I know a decent bit of java but this is completely dumbfounding me. I have got it so far to have the item class, but I cant get a gui to appear on right-click

 

This is my item class

 

package archangel.necromancy.item;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import archangel.necromancy.Necromancy;

import archangel.necromancy.lib.GuiIds;

import archangel.necromancy.lib.Strings;

 

public class ItemNecronomicon extends ItemNC {

 

    public ItemNecronomicon(int id) {

 

        super(id);

        this.setIconCoord(0, 0);

        this.setItemName(Strings.NECRONOMICON_NAME);

        this.setCreativeTab(Necromancy.tabsNecro);

        maxStackSize = 1;

       

    }

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)

    {

        player.openGui(Necromancy.instance, GuiIds.NECRONOMICON, world, 0, 0, 0);

        return itemstack;

    }

}

 

 

My ItemNC class

 

package archangel.necromancy.item;

 

import net.minecraft.item.Item;

import archangel.necromancy.lib.Reference;

import archangel.necromancy.lib.Sprites;

 

public class ItemNC extends Item {

 

    public ItemNC(int id) {

 

        super(id - Reference.SHIFTED_ID_RANGE_CORRECTION);

        maxStackSize = 1;

        setTextureFile(Sprites.SPRITE_SHEET_LOCATION + Sprites.ITEM_SPRITE_SHEET);

        setNoRepair();

    }

 

}

 

 

 

ModItems

 

package archangel.necromancy.item;

 

import net.minecraft.item.Item;

import archangel.necromancy.lib.ItemIds;

 

public class ModItems {

 

    /* Mod item instances */

    public static Item necronomicon;

    public static void init() {

 

        /* Initialize each mod item individually */

        necronomicon = new ItemNecronomicon(ItemIds.NECRONOMICON);

 

//        necronomicon.setContainerItem(necronomicon);

 

    }

}

 

 

 

I have figured that I need to make a GuiScreen class since I can't use tile entities for an item. I have been looking at the GuiScreenBook.class but I cannot make much sense out of it where I get a usable result. I have been google'ing solutions for a while now and either I am doing it wrong or I can't find anything other than GUI's for blocks. I would prefer guidance as to what to do/look for instead of handouts. I appreciate any help and advice. Thanks

Link to comment
Share on other sites

That doesn't seem to work I am still not having any gui's pop up on rightclick. I'm fairly sure I am using the correct instance, but how would I tell for sure?

This is my main class file

 

package archangel.necromancy;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraftforge.common.MinecraftForge;

import archangel.necromancy.block.ModBlocks;

import archangel.necromancy.configuration.ConfigurationHandler;

import archangel.necromancy.core.handlers.ActionRequestHandler;

import archangel.necromancy.core.handlers.EntityLivingHandler;

import archangel.necromancy.core.handlers.ItemPickupHandler;

import archangel.necromancy.core.handlers.PlayerDestroyItemHandler;

import archangel.necromancy.core.helper.LogHelper;

import archangel.necromancy.core.proxy.CommonProxy;

import archangel.necromancy.creativetab.CreativeTabNecro;

import archangel.necromancy.item.ModItems;

import archangel.necromancy.lib.Reference;

import archangel.necromancy.network.PacketHandler;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.Mod.ServerStarting;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.event.FMLServerStartingEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.network.NetworkRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME,

        version = Reference.VERSION)

@NetworkMod(channels = { Reference.CHANNEL_NAME }, clientSideRequired = true,

        serverSideRequired = false, packetHandler = PacketHandler.class)

public class Necromancy {

 

    @Instance(Reference.MOD_ID)

    public static Necromancy instance;

 

    @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS,

            serverSide = Reference.SERVER_PROXY_CLASS)

    public static CommonProxy proxy;

 

    public static CreativeTabs tabsNecro = new CreativeTabNecro(CreativeTabs.getNextID(), Reference.MOD_ID);

 

    @ServerStarting

    public void serverStarting(FMLServerStartingEvent event) {

 

    }

 

    @PreInit

    public void preInit(FMLPreInitializationEvent event) {

 

        // Initialize the log helper

        LogHelper.init();

 

        // Initialize the configuration

        ConfigurationHandler.init(event.getSuggestedConfigurationFile());

 

        // Initialize the Render Tick Handler (Client only)

        proxy.registerRenderTickHandler();

 

        // Register the KeyBinding Handler (Client only)

        proxy.registerKeyBindingHandler();

 

        // Register the Sound Handler (Client only)

        proxy.registerSoundHandler();

 

    }

 

    @Init

    public void load(FMLInitializationEvent event) {

 

    //Fixes creative tab name

LanguageRegistry.instance().addStringLocalization("itemGroup.Necromancy", "en_US", "Necromancy");

 

        // Register the GUI Handler

        NetworkRegistry.instance().registerGuiHandler(instance, proxy);

 

        // Register the PlayerDestroyItem Handler

        MinecraftForge.EVENT_BUS.register(new PlayerDestroyItemHandler());

 

        // Register the Item Pickup Handler

        MinecraftForge.EVENT_BUS.register(new ItemPickupHandler());

 

        // Register the EntityLiving Handler

        MinecraftForge.EVENT_BUS.register(new EntityLivingHandler());

 

        MinecraftForge.EVENT_BUS.register(new ActionRequestHandler());

 

 

        // Initialize mod blocks

        ModBlocks.init();

 

        // Initialize mod items

        ModItems.init();

 

        // Initialize mod tile entities

        proxy.initTileEntities();

 

        // Initialize custom rendering and pre-load textures (Client only)

        proxy.initRenderingAndTextures();

 

    }

 

    @PostInit

    public void modsLoaded(FMLPostInitializationEvent event) {

 

 

    }

}

 

 

Link to comment
Share on other sites

Okay I figured some of this out and I now have a GUI appearing on right click, but how would I do this without mod loader?

 

ItemNecronomicon

 

package archangel.necromancy.item;

 

import net.minecraft.client.entity.EntityPlayerSP;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.item.ItemStack;

import net.minecraft.src.ModLoader;

import net.minecraft.world.World;

import archangel.necromancy.Necromancy;

import archangel.necromancy.client.gui.inventory.GuiNecronomicon;

import archangel.necromancy.lib.Strings;

 

public class ItemNecronomicon extends ItemNC {

 

    public ItemNecronomicon(int id) {

 

        super(id);

        this.setIconCoord(0, 0);

        this.setItemName(Strings.NECRONOMICON_NAME);

        this.setCreativeTab(Necromancy.tabsNecro);

        maxStackSize = 1;

       

    }

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)

    {

    if(player instanceof EntityPlayerMP)

    {

    /*

    * If your gui is a container add it here. The TileEntity itself also to be stored so, that it is accessable in this method

    * And don't forget to register the ContainerID in the mod_** class

    *

    * If your GUI is NOT a container you leave the if-block blank.

    */

 

  //  ModLoader.serverOpenWindow((EntityPlayerMP)player, new ContainerYours(/*your parameters for the constructor*/);

    }

    else

    {

    ModLoader.openGUI((EntityPlayerSP)player, new GuiNecronomicon(player /*your parameters for the constructor*/));

    }

return itemstack;

}

}

 

GuiNecronomicon

 

package archangel.necromancy.client.gui.inventory;

 

import net.minecraft.client.gui.GuiScreen;

import net.minecraft.entity.player.EntityPlayer;

 

import org.lwjgl.opengl.GL11;

 

import archangel.necromancy.lib.Sprites;

 

public class GuiNecronomicon extends GuiScreen {

public GuiNecronomicon(EntityPlayer player) {

 

}

 

public final int xSizeOfTexture = 176;

public final int ySizeOfTexture = 88;

 

@Override

public void drawScreen(int x, int y, float f) {

drawDefaultBackground();

 

int var4 = this.mc.renderEngine.getTexture(Sprites.GUI_SHEET_LOCATION + Sprites.NECRONOMICON_MODEL_TEXTURE);

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

this.mc.renderEngine.bindTexture(var4);

 

int posX = (this.width - xSizeOfTexture) / 2;

int posY = (this.height - ySizeOfTexture) / 2;

 

drawTexturedModalRect(posX, posY, 0, 0, xSizeOfTexture, ySizeOfTexture);

 

super.drawScreen(x, y, f);

}

 

@Override

public boolean doesGuiPauseGame() {

return false;

}

 

@Override

protected void keyTyped(char par1, int par2) {

if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.keyCode) {

this.mc.thePlayer.closeScreen();

}

}

}

 

Link to comment
Share on other sites

How would I go about doing that? I'm sorry I just don't see ANY tutorials whatsoever for making GUI's for items in forge. The best I found was modloader and I would prefer not using modloader. I'm trying to basically have it like in thaumcraft where you will open a book and it will have instructions/recipes to the things the player will be doing, as well as the book being used in a receptacle and when the book is in the receptacle you will have a new gui extending from the block that will act as a container/tile entity. I'm not sure if what I am trying to do with the book requires it to be a tile entity or a container, and what code is required to set it up in the guiscreen/proxy/item class or where to find references on how to do it. I have it working perfectly with the block acting as a container and it has its gui but this has me completely stumped.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot88 Viral = Situs Slot88 Gacor Modal Receh Gampang Menang Viral Slot88 Online Min Depo 1000 1RB 1K 1ribu Tanpa Potongan ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Slot88 Viral menjadi sorotan para pecinta slot online dengan berbagai fitur menarik yang ditawarkan. Berikut adalah ulasan singkat tentang situs ini: Slot88 Gacor Modal Receh Slot88 Viral menawarkan pengalaman bermain slot online yang menarik dengan modal yang sangat terjangkau. Dengan deposit mulai dari 1000, 1RB, 1K, hingga 1ribu tanpa potongan, Anda dapat langsung memulai petualangan Anda untuk mencari kemenangan besar. Gampang Menang di Slot88 Online Salah satu daya tarik utama dari Slot88 Viral adalah peluang besar untuk meraih kemenangan. Dengan berbagai pilihan permainan slot gacor yang disediakan, para pemain memiliki kesempatan yang lebih besar untuk mendapatkan jackpot dan hadiah besar lainnya. Min Depo Tanpa Potongan Slot88 Viral memastikan bahwa setiap transaksi deposit dilakukan tanpa potongan, sehingga Anda dapat menggunakan seluruh saldo deposit Anda untuk bermain tanpa kehilangan sebagian karena biaya transaksi. Ini memberi Anda nilai yang lebih besar untuk setiap deposit yang Anda lakukan. Viral di Kalangan Pecinta Slot Online Slot88 Viral telah menjadi viral di kalangan pecinta slot online karena reputasinya yang baik dalam menyediakan pengalaman bermain yang adil, transparan, dan menguntungkan bagi para pemainnya. Dengan jumlah pemain yang terus bertambah, situs ini terus memperkuat posisinya sebagai salah satu destinasi utama untuk bermain slot online. Jadi, jika Anda mencari situs slot online yang menarik, menghibur, dan memberikan peluang besar untuk menang, Slot88 Viral adalah pilihan yang tepat. Bergabunglah sekarang dan rasakan sensasi bermain di salah satu situs slot paling populer di dunia daring!  
    • Slot Deposit 1000 Via Dana = Situs Slot Online Gacor Modal Receh Tanpa potongan Deposit 1rb 1000 1k 1ribu 5k 5ribu 5000 Dana ▶️▶️DAFTAR◀️◀️ ▶️▶️DAFTAR◀️◀️ Dalam dunia perjudian daring, menemukan situs yang menawarkan deposit terjangkau dengan peluang besar untuk menang adalah impian setiap pemain. Salah satu situs yang patut dipertimbangkan adalah Lambo77. Berikut adalah ulasan singkat tentang situs ini: Deposit 1000 Via Dana Tanpa Potongan Lambo77 menawarkan kesempatan kepada para pemain untuk melakukan deposit melalui layanan Dana dengan nominal seribu tanpa dikenakan potongan apa pun. Ini memberi Anda kemudahan dan fleksibilitas dalam melakukan transaksi. Modal Receh dengan Deposit 1rb 1000 1k 1ribu 5k 5ribu 5000 Situs ini memahami bahwa tidak semua pemain memiliki modal besar untuk bermain. Oleh karena itu, mereka menyediakan opsi deposit dengan nominal yang sangat terjangkau, mulai dari 1rb hingga 5000, sehingga siapa pun bisa bergabung dan merasakan keseruan permainan slot. Slot Online Gacor dengan Peluang Menang Besar Lambo77 dikenal sebagai tempat di mana para pemain bisa menemukan slot online yang gacor, artinya memiliki peluang besar untuk meraih kemenangan. Dengan modal receh yang Anda depositkan, Anda bisa bermain dan memiliki kesempatan untuk memenangkan hadiah besar. Tanpa Potongan Salah satu keuntungan utama bermain di Lambo77 adalah tidak adanya potongan dalam setiap transaksi deposit. Ini berarti Anda dapat menggunakan seluruh saldo yang Anda depositkan untuk bermain tanpa kehilangan sebagian karena potongan. Dengan kombinasi deposit yang terjangkau, peluang menang yang besar, dan transaksi tanpa potongan, Lambo77 menjadi pilihan yang sangat menarik bagi para pecinta slot online. Jadi, jangan ragu untuk bergabung dan rasakan keseruannya sekarang juga!  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.