diff options
author | llk89 <27812632+llk89@users.noreply.github.com> | 2021-08-17 05:39:35 +0800 |
---|---|---|
committer | llk89 <27812632+llk89@users.noreply.github.com> | 2021-08-17 05:51:07 +0800 |
commit | 5fd50a358464907982a696b977a17e14227b44aa (patch) | |
tree | 63bc6e4c9e4d7e2404937d05214cf5939bb7590e /src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java | |
parent | b00aebd72df14381b08639d86d65a04439289302 (diff) | |
download | GT5-Unofficial-5fd50a358464907982a696b977a17e14227b44aa.tar.gz GT5-Unofficial-5fd50a358464907982a696b977a17e14227b44aa.tar.bz2 GT5-Unofficial-5fd50a358464907982a696b977a17e14227b44aa.zip |
Fix NeutronSensor GUI sync
Diffstat (limited to 'src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java')
-rw-r--r-- | src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java b/src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java new file mode 100644 index 0000000000..0b3c045ece --- /dev/null +++ b/src/main/java/GoodGenerator/Network/MessageOpenNeutronSensorGUI.java @@ -0,0 +1,50 @@ +package GoodGenerator.Network; + +import GoodGenerator.Blocks.TEs.MetaTE.NeutronSensor; +import com.github.technus.tectech.TecTech; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import io.netty.buffer.ByteBuf; + +public class MessageOpenNeutronSensorGUI extends MessageMTEBase { + protected String data; + + public MessageOpenNeutronSensorGUI() { + } + + public MessageOpenNeutronSensorGUI(IGregTechTileEntity tile, String data) { + super(tile); + this.data = data; + } + + @Override + public void fromBytes(ByteBuf buf) { + super.fromBytes(buf); + data = ByteBufUtils.readUTF8String(buf); + } + + @Override + public void toBytes(ByteBuf buf) { + super.toBytes(buf); + ByteBufUtils.writeUTF8String(buf, data); + } + + public static class ClientHandler extends MessageMTEBase.Handler<MessageOpenNeutronSensorGUI, IMessage> { + @Override + protected IMessage onError(MessageOpenNeutronSensorGUI message, MessageContext ctx) { + return null; + } + + @Override + protected IMessage onSuccess(MessageOpenNeutronSensorGUI message, MessageContext ctx, IMetaTileEntity mte) { + if (mte instanceof NeutronSensor) { + ((NeutronSensor) mte).setText(message.data); + mte.getBaseMetaTileEntity().openGUI(TecTech.proxy.getPlayer()); + } + return null; + } + } +} |