diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-01-08 19:58:35 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-01-08 19:58:35 +1000 |
commit | f357e3a1753c7c542d48bb217d8a2545cb9544c4 (patch) | |
tree | 940bdbf5bfafc6faa7ccbc810f6b2e59367aca9b /src/Java/gtPlusPlus/core/handler/PacketHandler.java | |
parent | 2b77e70b058ed0a82b3a4a163a04ec5d9ed00c67 (diff) | |
download | GT5-Unofficial-f357e3a1753c7c542d48bb217d8a2545cb9544c4.tar.gz GT5-Unofficial-f357e3a1753c7c542d48bb217d8a2545cb9544c4.tar.bz2 GT5-Unofficial-f357e3a1753c7c542d48bb217d8a2545cb9544c4.zip |
+ Added an interface to make tooltips on tile entities more flexible.
+ Actually added the recipe for the Mining Explosives this time.
+ Attempted to add a framework for packet handling.
Diffstat (limited to 'src/Java/gtPlusPlus/core/handler/PacketHandler.java')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/PacketHandler.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/PacketHandler.java b/src/Java/gtPlusPlus/core/handler/PacketHandler.java new file mode 100644 index 0000000000..45eae28abc --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/PacketHandler.java @@ -0,0 +1,70 @@ +package gtPlusPlus.core.handler; + +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; + +public class PacketHandler { + + public static SimpleNetworkWrapper packetLightning; + + public PacketHandler(){ + packetLightning = NetworkRegistry.INSTANCE.newSimpleChannel("gtpp_Lightning"); + packetLightning.registerMessage(Packet_Lightning_Handler.class, Packet_Lightning.class, 0, Side.SERVER); + } + + + + + /** + * Internal Packet Handlers + * @author Alkalus + * + */ + + private class Packet_Lightning implements IMessage{ + + public void sendTo(IMessage msg, EntityPlayerMP player){ + packetLightning.sendTo(msg, player); + } + + public void sendToServer(String string){ + packetLightning.sendToServer(new Packet_Lightning(string)); + } + + private String text; + + public Packet_Lightning(String text) { + this.text = text; + } + + @Override + public void fromBytes(ByteBuf buf) { + text = ByteBufUtils.readUTF8String(buf); // this class is very useful in general for writing more complex objects + } + + @Override + public void toBytes(ByteBuf buf) { + ByteBufUtils.writeUTF8String(buf, text); + } + + } + + private class Packet_Lightning_Handler implements IMessageHandler<Packet_Lightning, IMessage>{ + + @Override + public IMessage onMessage(Packet_Lightning message, MessageContext ctx) { + System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName())); + return null; // no response in this case + } + + } + + +} |