Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

Gui are client-side only, which means you can't reference it from a server file.

Now check the tutorials, please.

  • Author

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;
    }

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.

  • Author

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)

You need

@NetworkMod(clientSideRequired=true)

since you want both player (to see Gui) and server (to receive packets) to have your mod installed.

  • Author

I'm using

@NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"mychannel"}, packetHandler = PacketHandler.class)

 

but it didnt work

Caused by: java.lang.NoSuchMethodError: net.minecraft.block.Block.func_94330_A()Ljava/lang/String;

at Gigi10012.gigisMod.preInit(gigisMod.java:59)

Show us your gigisMod.java, and highlight line 59, please.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.