Use that weird new runnable thing now.

Thanks to Blay09 for noticing that for me :v
This commit is contained in:
Ellpeck 2016-08-15 17:13:43 +02:00
parent cba12aabe0
commit 81f743f03d
2 changed files with 22 additions and 8 deletions

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
@ -59,10 +60,16 @@ public class PacketClientToServer implements IMessage{
public static class Handler implements IMessageHandler<PacketClientToServer, IMessage>{ public static class Handler implements IMessageHandler<PacketClientToServer, IMessage>{
@Override @Override
public IMessage onMessage(PacketClientToServer message, MessageContext ctx){ public IMessage onMessage(PacketClientToServer aMessage, MessageContext ctx){
final PacketClientToServer message = aMessage;
FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new Runnable(){
@Override
public void run(){
if(message.data != null && message.handler != null){ if(message.data != null && message.handler != null){
message.handler.handleData(message.data); message.handler.handleData(message.data);
} }
}
});
return null; return null;
} }
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.network;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
@ -62,10 +63,16 @@ public class PacketServerToClient implements IMessage{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IMessage onMessage(PacketServerToClient message, MessageContext ctx){ public IMessage onMessage(PacketServerToClient aMessage, MessageContext ctx){
final PacketServerToClient message = aMessage;
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
@Override
public void run(){
if(message.data != null && message.handler != null){ if(message.data != null && message.handler != null){
message.handler.handleData(message.data); message.handler.handleData(message.data);
} }
}
});
return null; return null;
} }
} }