Baubles

Baubles

116M Downloads

Network needs to be thread aware

williewillus opened this issue ยท 0 comments

commented

Example: https://github.com/Azanor/Baubles/blob/master/src/main/java/baubles/common/network/PacketSyncBauble.java#L50

In 1.8 and 1.9, packets are handled on the network thread.
Because of this, anything that touches the world, entities, or players is not thread safe and can have unexpected thread violations.

on the client side you have to wrap it with Minecraft.getMinecraft().addScheduledTask, on the server side ctx.getServerHandler().playerEntity.mcServer.addScheduledTask, passing it a Runnable that actually does the work. It'll get run the next tick.

see the warning halfway down here: http://mcforge.readthedocs.org/en/latest/networking/simpleimpl/