Jump to content

szabopeter2011

Members
  • Posts

    9
  • Joined

  • Last visited

szabopeter2011's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I don't know either, I'll make it local variable. Anyways, thank you very very very much for your help!
  2. I made it using ReflectionHelper.findField, and it works outside the development environment. private MinecraftServer server; @EventHandler public void onServerStarting(FMLServerStartingEvent event) throws IllegalAccessException, NoSuchFieldException { server = event.getServer(); PlayerList playerlist = server.getPlayerList(); Field field = ReflectionHelper.findField(PlayerList.class,"maxPlayers","field_72405_c"); field.setAccessible(true); field.set(playerlist, 15); } Is it okay now?
  3. Oops, I didn't know that. Thanks for the warning! I'll try to do it that way, tomorrow.
  4. private static MinecraftServer server; @EventHandler public void onServerStarting(FMLServerStartingEvent event) throws IllegalAccessException, NoSuchFieldException { server = event.getServer(); PlayerList playerlist = server.getPlayerList(); Field field = PlayerList.class.getDeclaredField("maxPlayers"); field.setAccessible(true); field.set(playerlist, 15); }
  5. Thank you very much! You solved my problem! This was the final thing I needed! I'will soon post the code that worked, for beginners like me.
  6. Thanks for your reply! Can you please tell me or show me an example of how to get an instance? Sorry for being a noob, but I'm trying it since you replied, and can't figure it out. Thank you in advance!
  7. Thanks for your reply! I tried it with reflection many times, without success. The code I used was: Field field = PlayerList.class.getDeclaredField("maxPlayers"); field.setAccessible(true); field.set(field, 15); This gave me a java.lang.IllegalArgumentException: Can not set int field net.minecraft.server.management.PlayerList.maxPlayers to java.lang.reflect.Field After this I looked for an example. I found and tried this: Class<?> clazz = PlayerList.class; Object cc = clazz.newInstance(); Field f1 = cc.getClass().getSuperclass().getDeclaredField("maxPlayers"); f1.setAccessible(true); f1.set(cc, 15); This did not work either and gave me a lot of errors. I think the most important was this: java.lang.InstantiationException: net.minecraft.server.management.PlayerList I don't understand why neither of these worked, so I'm asking for your help again. Can you please tell me what to do/correct? Thank you in advance!
  8. Thanks for your reply! I just tried what you said, but it does not work, because I couldn't set a value for maxPlayers because it's protected/private(?). Can you help me about this, or do you have other suggestion? Thank you in advance!
  9. Hi, I'm quite new to forge gradle, but I made some simple mods already. Now I decided to create a mod that can increase the maximum amount of players that can play on an "open to lan" server. The problem is that I couldn't find any help on the internet about this, and I don't know where to start. Please help me carry this out! Any help would be greatly apprecciated! Thank you in advance, and sorry about my english!
×
×
  • Create New...

Important Information

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