package landmaster.plustic.net;

import io.netty.buffer.*;
import landmaster.plustic.api.*;
import net.minecraft.client.*;
import net.minecraftforge.fml.common.network.*;
import net.minecraftforge.fml.common.network.simpleimpl.*;

public class PacketUpdateToggleGui implements IMessage, IMessageHandler<PacketUpdateToggleGui, IMessage> {
	private String identifier;
	private boolean value;
	
	public PacketUpdateToggleGui() {}
	public PacketUpdateToggleGui(String identifier, boolean value) {
		this.identifier = identifier;
		this.value = value;
	}

	@Override
	public IMessage onMessage(PacketUpdateToggleGui message, MessageContext ctx) {
		if (Minecraft.getMinecraft().currentScreen instanceof Toggle.Gui) {
			((Toggle.Gui)Minecraft.getMinecraft().currentScreen).update(message.identifier, message.value);
		}
		return null;
	}

	@Override
	public void fromBytes(ByteBuf buf) {
		identifier = ByteBufUtils.readUTF8String(buf);
		value = buf.readBoolean();
	}

	@Override
	public void toBytes(ByteBuf buf) {
		ByteBufUtils.writeUTF8String(buf, identifier);
		buf.writeBoolean(value);
	}
}

@@ -635,16 +635,69 @@
  ctx) %7B%0A
+%09%09Minecraft.getMinecraft().addScheduledTask(() -%3E %7B%0A%09
 %09%09if (Mi
@@ -758,16 +758,17 @@
 .Gui) %7B%0A
+%09
 %09%09%09((Tog
@@ -860,17 +860,24 @@
 lue);%0A%09%09
-%7D
+%09%7D%0A%09%09%7D);
 %0A%09%09retur

Increase thread safety