Posted October 15, 20196 yr I know it's good to schedule the messages received by the client and server in order to avoid crashes and bugs. However, should I make the messages scheduled or only a certain few? If so, how do I know which ones to add as a scheduled task? Any help is appreciated. Thanks Edited October 15, 20196 yr by Differentiation
October 15, 20196 yr Packet handling and the game are on different threads. Therefore, any actions concerning the game should be in a scheduled task (i.e. world manipulation, tile entity manipulation, etc). Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
October 15, 20196 yr Author 3 minutes ago, DavidM said: Packet handling and the game are on different threads. Therefore, any actions concerning the game should be in a scheduled task (i.e. world manipulation, tile entity manipulation, etc). So if I have something as simple as EntityPlayer::capabilities#allowFlight = true; in client handler I'd still need to schedule?
October 15, 20196 yr 1 minute ago, Differentiation said: So if I have something as simple as EntityPlayer::capabilities#allowFlight = true; in client handler I'd still need to schedule? I believe so. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
October 15, 20196 yr 16 hours ago, Differentiation said: should I make the messages scheduled or only a certain few? The simple answer is "any and all." The only time you wouldn't need to would be if you were going to send a new packet somewhere and did not need to interact with anything outside the handler's current scope. These situations will be so rare and edge-case as to be practically nonexistent. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 15, 20196 yr Author 6 hours ago, Draco18s said: The simple answer is "any and all." The only time you wouldn't need to would be if you were going to send a new packet somewhere and did not need to interact with anything outside the handler's current scope. These situations will be so rare and edge-case as to be practically nonexistent. Then... can I just do this? public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ> { @Override public REQ onMessage(REQ message, MessageContext context) { if (context.side == Side.SERVER) { EntityPlayerMP player = context.getServerHandler().player; player.getServer().addScheduledTask(new Runnable() { @Override public void run() { handleServerSide(message, player); } }); } else { EntityPlayer player = Dinocraft.PROXY.getPlayer(); Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { handleClientSide(message, player); } }); } return null; } public abstract void handleClientSide(REQ message, EntityPlayer player); public abstract void handleServerSide(REQ message, EntityPlayer player); } Edited October 15, 20196 yr by Differentiation
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.