Posted October 8, 201213 yr I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code: public void actionPerformed(GuiButton guibutton) { if(guibutton.id == 1) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(7000); } } if(guibutton.id == 2) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(17000); } } if(guibutton.id == 3) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(0); } } if(guibutton.id == 4) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(13000); } } } http://i.imgur.com/Hppni.png[/img]
October 8, 201213 yr I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code: public void actionPerformed(GuiButton guibutton) { if(guibutton.id == 1) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(7000); } } if(guibutton.id == 2) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(17000); } } if(guibutton.id == 3) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(0); } } if(guibutton.id == 4) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(13000); } } } Because the GUI classes are only called client-side. If you call MinecraftServer.getServer() in a client, it gives you only the InternalServer. If you are connected to a dedi server, it gives you a null object (unless you call this method on the dedi server). I would recommend to send packets for this one. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
October 8, 201213 yr Author I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code: public void actionPerformed(GuiButton guibutton) { if(guibutton.id == 1) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(7000); } } if(guibutton.id == 2) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(17000); } } if(guibutton.id == 3) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(0); } } if(guibutton.id == 4) { for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3) { MinecraftServer.getServer().theWorldServer[var3].setTime(13000); } } } Because the GUI classes are only called client-side. If you call MinecraftServer.getServer() in a client, it gives you only the InternalServer. If you are connected to a dedi server, it gives you a null object (unless you call this method on the dedi server). I would recommend to send packets for this one. oh gawd packets http://i.imgur.com/Hppni.png[/img]
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.