Jump to content

Having Troubles With Gui in 1.7.10


diamondguy2798

Recommended Posts

I am currently trying to get a gui to work but I am having one of two problems. When I setup the texture bind the game crashes when I attempt to open the gui,  without this it does not crash but instead has a random assortment of vanilla minecraft guis. I have looked at several tutorials only to realize that the way they were doing it was outdated so I would really appreciate any help that I can get.

 

I'm new to the forums (made this account to get help with this problem) so I apologize if my attempt to add the code goes badly.

 

 

Main

[embed=425,349]package gmail.marcusforrest0.com;

 

import cpw.mods.fml.common.Mod;

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

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.network.NetworkRegistry;

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

import gmail.marcusforrest0.blocks.Shrine;

import gmail.marcusforrest0.lib.Reference;

import gmail.marcusforrest0.modEvents.ModEventHandler;

import gmail.marcusforrest0.modEvents.ModGuiHandler;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraftforge.common.MinecraftForge;

 

@Mod(name = Reference.MOD_NAME, modid="classcraft", version=Reference.MOD_VERSION)

public class Main

{

 

public static String MODID = "classcraft";

public static String VERSION = "1.0";

 

public static CreativeTabs tabName = new CreativeTabs("Class Craft")

{

public Item getTabIconItem()

{

return Items.arrow;

}

};

 

 

 

public static Block shrine;

 

@Mod.Instance("classcraft") public static Main instance;

 

 

 

@EventHandler

public void preInit(FMLPreInitializationEvent e)

{

}

 

@EventHandler

public void init(FMLInitializationEvent e)

{

NetworkRegistry.INSTANCE.registerGuiHandler(this, new ModGuiHandler());

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

shrine = new Shrine(Material.wood).setCreativeTab(tabName).setBlockName("Shrine");

GameRegistry.registerBlock(shrine, "Shrine");

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent e)

{

}

 

}[/embed]

 

The Shrine Gui

[embed=425,349]package gmail.marcusforrest0.guiClients;

 

import org.lwjgl.opengl.GL11;

 

import gmail.marcusforrest0.com.Main;

import gmail.marcusforrest0.lib.Reference;

import net.minecraft.client.gui.GuiScreen;

import net.minecraft.util.ResourceLocation;

 

 

 

public class ShrineGui extends GuiScreen

{

int guiWidth = 175;

int guiHeight = 164;

private static ResourceLocation[] testing = new ResourceLocation[2];

 

public ShrineGui()

{

testing[0] = new ResourceLocation("classcraft:gui/shrine.png");

}

 

@Override

public void initGui()

{

System.out.println("Working");

}

 

@Override

public void updateScreen()

{

}

 

@Override

public boolean doesGuiPauseGame()

{

return false;

}

 

@Override

public void drawScreen(int x, int y, float ticks)

{

int guiX = (width - guiWidth)/2;

int guiY = (height - guiHeight)/2;

GL11.glColor4f(1, 1, 1, 1);

drawDefaultBackground();

//mc.getTextureManager().bindTexture(new ResourceLocation("classcraft:gui/shrine.png"));  commented out to do some debugging

drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);

fontRendererObj.drawString("Test", guiX, guiY, 0xFFFFFF);

 

 

super.drawScreen(x, y, ticks);

}

}

[/embed]

 

The Shrine Block

[embed=425,349]package gmail.marcusforrest0.blocks;

 

import gmail.marcusforrest0.com.Main;

import gmail.marcusforrest0.guiClients.ShrineGui;

import gmail.marcusforrest0.proxies.ClientProxy;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.world.World;

 

public class Shrine extends Block

{

 

public Shrine(Material material)

{

super(material);

}

 

@Override

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9)

{

 

if (!par1World.isRemote)

{

player.openGui(Main.instance, 0, par1World, par2, par3, par4);

Minecraft.getMinecraft().displayGuiScreen(new ShrineGui());

}

return true;

}

 

}

[/embed]

 

I have a decent amount of experience with Java but am very new to any and all minecraft modding practices and server/client relationships within java coding. Any help would be greatly appreciated, also please feel free to point out any poor coding practices so that I may get better.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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