package xyz.brassgoggledcoders.steamagerevolution.network;

import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import xyz.brassgoggledcoders.steamagerevolution.modules.steam.tileentities.TileEntityCastingBench;
import xyz.brassgoggledcoders.steamagerevolution.modules.storage.tileentities.TileEntityBasicFluidTank;

public class FluidUpdateHandler implements IMessageHandler<PacketFluidUpdate, IMessage> {
	public FluidUpdateHandler() {

	}

	@Override
	public IMessage onMessage(PacketFluidUpdate message, MessageContext ctx) {
		TileEntity te = Minecraft.getMinecraft().world.getTileEntity(message.pos);
		if(te instanceof TileEntityBasicFluidTank) {
			TileEntityBasicFluidTank tile = (TileEntityBasicFluidTank) te;
			tile.updateFluid(message.fluid);
		}
		else if(te instanceof TileEntityCastingBench) {
			TileEntityCastingBench tile = (TileEntityCastingBench) te;
			tile.updateFluid(message.fluid);
		}
		return null;
	}
}

@@ -92,16 +92,69 @@
 ecraft;%0A
+import net.minecraft.client.multiplayer.WorldClient;%0A
 import n
@@ -189,16 +189,16 @@
 Entity;%0A
-
 import n
@@ -824,21 +824,27 @@
 %7B%0A%09%09
-TileEntity te
+Minecraft minecraft
  = M
@@ -870,14 +870,314 @@
 ft()
-.world
+;%0A%09%09final WorldClient worldClient = minecraft.world;%0A%09%09minecraft.addScheduledTask(new Runnable() %7B%0A%09%09%09public void run() %7B%0A%09%09%09%09processMessage(worldClient, message);%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09return null;%0A%09%7D%0A%0A%09private void processMessage(WorldClient worldClient, PacketFluidUpdate message) %7B%0A%09%09TileEntity te = worldClient
 .get
@@ -1506,27 +1506,12 @@
 d);%0A
+
 %09%09%7D%0A
-%09%09return null;%0A
 %09%7D%0A%7D

Handle network vs client thread correctly