Posted October 15, 201311 yr 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?
October 15, 201311 yr Author I have created GUI. everything works fine on client but i cant install it on server (I'm using mcpc-plus server http://www.mcportcentral.co.za/)
October 15, 201311 yr Gui are client-side only, which means you can't reference it from a server file. Now check the tutorials, please.
October 16, 201311 yr 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; }
October 16, 201311 yr 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.
October 16, 201311 yr 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)
October 16, 201311 yr You need @NetworkMod(clientSideRequired=true) since you want both player (to see Gui) and server (to receive packets) to have your mod installed.
October 16, 201311 yr Author I'm using @NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"mychannel"}, packetHandler = PacketHandler.class) but it didnt work
October 17, 201311 yr 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.