Jump to content

Forge 1.5.2 Server GUI Problem


Gigi10012

Recommended Posts

Hello,

I want to Make mod that Adds Block, and When Player will right click it, it will open gui with

buttons and textboxes. when player will click one of the buttons mod will execute server command as console.

 

I made Mod that Adds Block but it can only open GUI when player is in singleplayer. when i start mcpc-plus 1.5.2 server it says that it cant find GuiScreen class. i wont my mod to work on server and players were able to place blocks on server, open GUI when they rightclick block and when they will click buttons it will execute server command as console. How to do this?

Link to comment
Share on other sites

so its means its impossible to make block that opens GUI when more than two players are playing ?

(i have already made block and GUI but they are working only on test mode)

 

Heres My Code to open GUI:

    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c)
    {
    	if(player.getCurrentEquippedItem() != null)
    	{
    		Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
    		Item it123 = Main.myitem;
    		if(equipped.equals(it123))
    		{
    			ModLoader.openGUI(player, new mygui(player));
    		}
    	}
    	return true;
    }

Link to comment
Share on other sites

so its means its impossible to make block that opens GUI when more than two players are playing ?

No, not if you do it like the tutorials say it should be done.

 

ModLoader.openGUI(player, new mygui(player));

Which is not with a ModLoader method. Use IGuiHandler, and use EntityPlayer.openGui() on the server side only. Like GotoLink said twice, check tutorials.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Link to comment
Share on other sites

Ok. i added Gui Handler and changed code.

 

Gui Handler:

public class myGuiHandler implements IGuiHandler {
    //returns an instance of the Container you made earlier
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) 
    {
    	if(id == 0)
    	{
            return new myGui1(player);
    	}
    	else if(id == 1)
    	{
    		return new myGui2(player);
    	}
    	return null;
    }

    //returns an instance of the Gui you made earlier
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) 
    {
    	if(id == 0)
    	{
            return new myGui1(player);
    	}
    	else if(id == 1)
    	{
    		return new myGui2(player);
    	}
    	return null;
    }
}

 

on test run it says that mod tried to open gui without being a NetworkMod

and on block to open GuiScreen i used:

player.openGui(gigsMod.instance, 0, world, x, y, z);

 

i have compiled it and placed it on mcpc-plus server but it gave strange error:

 

	at cpw.mods.fml.common.LoadController.transition(LoadController.java:147)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:516)
at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:85)
at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:350)
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:94)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:574)
at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)
Caused by: java.lang.NoSuchMethodError: net.minecraft.block.Block.func_94330_A()Ljava/lang/String;
at Gigi10012.gigisMod.preInit(gigisMod.java:59)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)
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:45)
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:192)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)
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:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

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



×
×
  • Create New...

Important Information

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