Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.2]NetworkRegistry


Z@Nka
 Share

Recommended Posts

I have this problem where I cant register my "GuiHandler". I am not sure if its just something i missed or what but i cant test by new code because the game cant start.

The code i am using is:

NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());

I have tried putting it into Init/Load and i did put it in normally. None of it worked. :'(

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

u need to say this, because u r giving an instance of its own class

 

NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());

*********************************

**  Always remember you are unique,  **

**  just like everyone else                   **     

**********************************

Was my post helpful? Say thanks and

press the thank you button, on my post!!

God, damn it!

Link to comment
Share on other sites

Crash report:

---- Minecraft Crash Report ----
// Surprise! Haha. Well, this is awkward.

Time: 07.03.14 22:01
Description: Initializing game

java.lang.RuntimeException: Invalid attempt to create a GUI during mod construction. Use an EventHandler instead
at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:218)
at bulkyzanka.electro.mod.Electrocuted.<init>(Electrocuted.java:143)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:509)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:484)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:564)
at net.minecraft.client.Minecraft.run(Minecraft.java:934)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:218)
at bulkyzanka.electro.mod.Electrocuted.<init>(Electrocuted.java:143)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:509)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:484)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:564)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:934)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_21, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 197018256 bytes (187 MB) / 378011648 bytes (360 MB) up to 1905197056 bytes (1816 MB)
JVM Flags: 0 total; 
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.125.1031 Minecraft Forge 10.12.0.1031 5 mods loaded, 5 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed
FML{7.2.125.1031} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1031.jar) Unloaded->Constructed
Forge{10.12.0.1031} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1031.jar) Unloaded->Constructed
examplemod{1.0} [Example Mod] (bin) Unloaded->Constructed
electro{1.0A} [Electrocuted] (bin) Unloaded->Errored
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: AMD Radeon HD 6800 Series GL version 4.2.12422 Compatibility Profile Context 13.152.0.0, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: ~~ERROR~~ NullPointerException: null
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Anisotropic Filtering: Off (1)

 

Main class:

package bulkyzanka.electro.mod;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.util.EnumHelper;
import bulkyzanka.electro.mod.blocks.BlockCompressionFurnace;
import bulkyzanka.electro.mod.blocks.Test;
import bulkyzanka.electro.mod.creativetabs.ElectrocutedTab;
import bulkyzanka.electro.mod.gui.GuiHandler;
import bulkyzanka.electro.mod.items.BoneIngot;
import bulkyzanka.electro.mod.items.BonePlate;
import bulkyzanka.electro.mod.items.CoalMotor;
import bulkyzanka.electro.mod.items.ElectricMotor;
import bulkyzanka.electro.mod.items.Generator;
import bulkyzanka.electro.mod.items.armor.BoneArmor;
import bulkyzanka.electro.mod.items.tools.BoneAxe;
import bulkyzanka.electro.mod.items.tools.BoneHoe;
import bulkyzanka.electro.mod.items.tools.BonePickaxe;
import bulkyzanka.electro.mod.items.tools.BoneSpade;
import bulkyzanka.electro.mod.items.tools.BoneSword;
import bulkyzanka.electro.mod.lib.Referance;
import bulkyzanka.electro.mod.proxy.ProxyCommon;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
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.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;



@Mod(modid = Referance.MODID, version = Referance.VERSION)
public class Electrocuted
{

//Instance
@Instance(Referance.MODID)
    public static Electrocuted instance;

//Proxy Stuff
@SidedProxy(clientSide = "electro.proxy.ProxyClient" , serverSide = "electro.proxy.ProxyCommon")
public static ProxyCommon proxy;

//GuiIDs
public static final int guiIdCompressionFurnace = 1;
//CreativeTabs
public static CreativeTabs  ElectrocutedTab = new ElectrocutedTab(CreativeTabs.getNextID(), "ElectrocutedTab");

//Material
	//ToolMaterial
public static ToolMaterial Bone = EnumHelper.addToolMaterial("Bone", 2, 175, 6.0F, 2.5F, 19);

	//ArmorMaterial
public static ArmorMaterial BoneArmor = EnumHelper.addArmorMaterial("BONEARMOR", 7, new int[]{3, 7, 6, 3}, 20);

//Items
public static Item BonePlate = new BonePlate().setUnlocalizedName("BonePlate").setTextureName("electrocuted:BonePlate");
public static Item BoneIngot = new BoneIngot().setUnlocalizedName("BoneIngot").setTextureName("electrocuted:BoneIngot");
public static Item CoalMotor = new CoalMotor().setUnlocalizedName("CoalMotor").setTextureName("electrocted:CoalMotor");
public static Item ElectricMotor = new ElectricMotor().setUnlocalizedName("ElectricMotor").setTextureName("electrocted:ElectricMotor");
public static Item Generator = new Generator().setUnlocalizedName("Generator").setTextureName("electrocted:Generator");

//Blocks
public static Block CompressionFurnaceIdle = new BlockCompressionFurnace(false).setBlockName("CompressionFurnaceIdle").setBlockTextureName("electrocuted:CompressionFurnace_Idle_front");
public static Block CompressionFurnaceActive = new BlockCompressionFurnace(true).setBlockName("CompressionFurnaceActive").setBlockTextureName("electrocuted:CompressionFurnace_Idle_front");

//Tools
public static Item BoneSword = new BoneSword(Bone).setUnlocalizedName("BoneSword").setTextureName("electrocuted:BoneSword");
public static Item BoneSpade = new BoneSpade(Bone).setUnlocalizedName("BoneSpade").setTextureName("electrocuted:BoneSpade");
public static Item BonePickaxe = new BonePickaxe(Bone).setUnlocalizedName("BonePickaxe").setTextureName("electrocuted:BonePickaxe");
public static Item BoneAxe = new BoneAxe(Bone).setUnlocalizedName("BoneAxe").setTextureName("electrocuted:BoneAxe");
public static Item BoneHoe = new BoneHoe(Bone).setUnlocalizedName("BoneHoe").setTextureName("electrocuted:BoneHoe");

//Armor
public static Item BoneHelmet = new BoneArmor(BoneArmor, 0).setUnlocalizedName("BoneHelmet").setTextureName("electrocuted:BoneHelmet");
public static Item BoneChestPlate = new BoneArmor(BoneArmor, 1).setUnlocalizedName("BoneChestPlate").setTextureName("electrocuted:BoneChestPlate");
public static Item BoneLeggings = new BoneArmor(BoneArmor, 2).setUnlocalizedName("BoneLeggings").setTextureName("electrocuted:BoneLeggings");
public static Item BoneBoots = new BoneArmor(BoneArmor, 3).setUnlocalizedName("BoneBoots").setTextureName("electrocuted:BoneBoots");

 //EventHandler
	//PreInit
@EventHandler
 public void preinit(FMLPreInitializationEvent event)
{
	//Config
	Configuration config = new Configuration(
			event.getSuggestedConfigurationFile());
			config.load();

			config.save();
 }

//Init
 @EventHandler
 public void init(FMLInitializationEvent event)
 {
	 proxy.registerRenderInformation();
	 proxy.registerTileEntities();
 }	 

 	//PostInit
 @EventHandler
 public void postinit(FMLPostInitializationEvent event)
 {

 }
public Electrocuted()
{

//Registry
 GameRegistry.registerItem(BonePlate, "BonePlate");
 GameRegistry.registerItem(BoneIngot, "BoneIngot");
 GameRegistry.registerItem(CoalMotor, "CoalMotor");
 GameRegistry.registerItem(ElectricMotor, "ElectricMotor");
 GameRegistry.registerItem(Generator, "Generator");

 GameRegistry.registerBlock(CompressionFurnaceIdle, "CompressionFurnaceIdle");
 GameRegistry.registerBlock(CompressionFurnaceActive, "CompressionFurnaceActive");

 GameRegistry.registerItem(BoneSword, "BoneSword");
 GameRegistry.registerItem(BoneSpade, "BoneSpade");
 GameRegistry.registerItem(BonePickaxe, "BonePickaxe");
 GameRegistry.registerItem(BoneAxe, "BoneAxe");
 GameRegistry.registerItem(BoneHoe, "BoneHoe");

 GameRegistry.registerItem(BoneHelmet, "BoneHelmet");
 GameRegistry.registerItem(BoneChestPlate, "BoneChestPlate");
 GameRegistry.registerItem(BoneLeggings, "BoneLeggings");
 GameRegistry.registerItem(BoneBoots, "BoneBoots");

 GuiHandler GuiHandler = new GuiHandler();
 LanguageRegistry.instance().addStringLocalization("container.CompressionFurnace", "Compression Furnace");
 NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

//Recipe
 	//Items
 GameRegistry.addRecipe(new ItemStack(BonePlate, 2), new Object []
 {
		"XX ", "XX ", 'X', Items.bone
 });
 GameRegistry.addRecipe(new ItemStack(BoneIngot, 3), new Object []
 {
	"XXX", "XYX", "XXX", 'X', Items.bone, 'Y', Items.iron_ingot
 });

 	//Tools
 GameRegistry.addRecipe(new ItemStack(BoneSword, 1), new Object []
 {
	 " X ", " X ", " Y ", 'X', BoneIngot, 'Y', Items.stick
 });
 GameRegistry.addRecipe(new ItemStack(BoneSpade, 1), new Object []
 {
	 " X ", " Y ", " Y ", 'X', BoneIngot, 'Y', Items.stick
 });
 GameRegistry.addRecipe(new ItemStack(BonePickaxe, 1), new Object []
 {
	 "XXX", " Y ", " Y ", 'X', BoneIngot, 'Y', Items.stick
 });
 GameRegistry.addRecipe(new ItemStack(BoneAxe, 1), new Object []
 {
	 "XX ", "XY ", " Y ", 'X', BoneIngot, 'Y', Items.stick
 });
 GameRegistry.addRecipe(new ItemStack(BoneHoe, 1), new Object []
 {
	 " XX", " Y ", " Y ", 'X', BoneIngot, 'Y', Items.stick
 });


 	//Armor
 GameRegistry.addRecipe(new ItemStack(BoneHelmet, 1), new Object []
 {
	 "XXX", "X X", 'X', BonePlate
 });
 GameRegistry.addRecipe(new ItemStack(BoneChestPlate, 1), new Object []
 {
	 "X X", "XXX", "XXX", 'X', BonePlate
 });
 GameRegistry.addRecipe(new ItemStack(BoneLeggings, 1), new Object []
 {
	 "XXX", "X X", "X X", 'X', BonePlate
 });
 GameRegistry.addRecipe(new ItemStack(BoneBoots, 1), new Object []
 {
	 "X X", "X X", 'X', BonePlate
 });

}
}


If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

I'm sorry to ask but could you just tell me the code behind this, I am having a really hard time coding because i can't test anything.

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

I know what a constructor is but i don't understand where else to put it... I even looked at EE3 for referance and pahimar put it in init.

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

@EventHandler
@SuppressWarnings("unchecked, unused")
public void init(FMLInitializationEvent event)
{
// Register the GUI Handler
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
}

 

In my case it doesn't work.

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.