Obviously, this doesn't work on the server. I haven't used ModLoader.openGui before, so I don't really know how to use it with a class that extends GuiScreen. The other thing is that Gui classes aren't needed in the server, so you give it an id that is identified by the client. This is the ModLoader.openGui code that I'm using at the moment.
ModLoader.openGUI(entityplayer, 1, null, null);
I wasn't sure so I just put entityplayer as the first argument. The id of my gui is 1. I set the last two to null because my gui doesn't have the inventory usable, etc, and it doesn't operate with a container.
It gives this error, and disconnects the player with the message: "Internal Server Error".
[WARNING] Failed to handle packet: java.lang.NullPointerException
java.lang.NullPointerException
at net.minecraft.src.ModLoader.openGUI(ModLoader.java:827)
at net.minecraft.src.BlockSummoningTable.blockActivated(BlockSummoningTable.java:19)
at net.minecraft.src.ItemInWorldManager.activeBlockOrUseItem(ItemInWorldManager.java:255)
at net.minecraft.src.NetServerHandler.handlePlace(NetServerHandler.java:472)
at net.minecraft.src.Packet15Place.processPacket(Packet15Place.java:48)
at net.minecraft.src.NetworkManager.processReadPackets(NetworkManager.java:335)
at net.minecraft.src.NetServerHandler.handlePackets(NetServerHandler.java:72)
at net.minecraft.src.NetworkListenThread.handleNetworkListenThread(NetworkListenThread.java:114)
at net.minecraft.server.MinecraftServer.doTick(MinecraftServer.java:574)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:463)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:18)
I am 99% sure that the null pointer is caused by setting the last two arguments in the ModLoader.openGui method to null. What should I set the first, third and last argument to?
2. The second problem is in my TileEntity*** class.
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("summoningUsesRemaining", GuiSummoningTable.usesLeft);
}
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
GuiSummoningTable.usesLeft = par1NBTTagCompound.getInteger("summoningUsesRemaining");
}
The error is that GuiSummoningTable cannot be resolved to a variable. This is because GuiSummoningTable isn't in the server package, because gui classes aren't needed.
My question is, do I need to keep this TileEntity class? It does do some other things with the block, but they aren't needed or currently used.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I updated the OP with a bit more information and another problem I'm having, which is sort-of linked.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I updated the OP with a bit more information and another problem I'm having, which is sort-of linked.
1st of all, all of those variables have to be filled when you open the gui. Hints the "NullPointerException" What does your mod do because you may have to use packets instead of opening the gui though the server
The gui allows the player to spawn mobs. It operates off a single int which allows the player to spawn mobs through pressing buttons as long as the int is above a certain number.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I have the same problem... but I believe that GUIs are client-side handled only, not both sides..
It is true that you only need the gui class on the client, but when it is opened by clicking a block, opening a guiscreen presents a problem.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
In the gui class run a check in the button press event (or wherever) for the spawning and if the client is remote then have it send the id of the mob over to the server and have the server spawn the entity into the world using the id.
I'm pretty poor at explaining things but the steps would be:
1) client clicks the block which opens the gui
2) client clicks a button (or whatever) for the mob he wishes top spawn
3) the world is checked (remote/multiplayer)
4) if it's not then run the normal code, the one you have already in place (skip rest of steps)
5) send a 230 packet with a unique type (id) for the mob to the server
6) handle the packet on the server and spawn whichever mob the id refers to in the "HandlePacket"
No need for messing with server side gui stuff then.
The tile issue is basically the same thing, if it's not needed then remove it or use packets to update any data which the server relies on.
Thanks. That's pretty much the sort of thing I wanted to know. The only thing that I'm not sure about is saving the data individually to each block through the tile entity. At the moment, all of the blocks are linked together, but if it was to be like that in multiplayer, then people would be using others' stuff from their own table. The last thing I can't figure out is getting the gui to actually open without causing a crash.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
1. Getting the gui to open is the first issue. In the client, I use this method:
Obviously, this doesn't work on the server. I haven't used ModLoader.openGui before, so I don't really know how to use it with a class that extends GuiScreen. The other thing is that Gui classes aren't needed in the server, so you give it an id that is identified by the client. This is the ModLoader.openGui code that I'm using at the moment.
I wasn't sure so I just put entityplayer as the first argument. The id of my gui is 1. I set the last two to null because my gui doesn't have the inventory usable, etc, and it doesn't operate with a container.
It gives this error, and disconnects the player with the message: "Internal Server Error".
I am 99% sure that the null pointer is caused by setting the last two arguments in the ModLoader.openGui method to null. What should I set the first, third and last argument to?
2. The second problem is in my TileEntity*** class.
The error is that GuiSummoningTable cannot be resolved to a variable. This is because GuiSummoningTable isn't in the server package, because gui classes aren't needed.
My question is, do I need to keep this TileEntity class? It does do some other things with the block, but they aren't needed or currently used.
together they are powerful beyond imagination."
together they are powerful beyond imagination."
1st of all, all of those variables have to be filled when you open the gui. Hints the "NullPointerException" What does your mod do because you may have to use packets instead of opening the gui though the server
Follow @jamolnng
The best way to contact me is via twitter.
together they are powerful beyond imagination."
Mjölnir Hammer Mod
It is true that you only need the gui class on the client, but when it is opened by clicking a block, opening a guiscreen presents a problem.
together they are powerful beyond imagination."
Thanks. That's pretty much the sort of thing I wanted to know. The only thing that I'm not sure about is saving the data individually to each block through the tile entity. At the moment, all of the blocks are linked together, but if it was to be like that in multiplayer, then people would be using others' stuff from their own table. The last thing I can't figure out is getting the gui to actually open without causing a crash.
together they are powerful beyond imagination."
together they are powerful beyond imagination."