Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Looke81.BioWarfare;
- import cpw.mods.fml.common.network.ByteBufUtils;
- 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 io.netty.buffer.ByteBuf;
- public class MyMessage implements IMessage {
- public static class Handler implements IMessageHandler<MyMessage, IMessage> {
- @Override
- public IMessage onMessage(MyMessage message, MessageContext ctx) {
- System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName()));
- BioWarfare.Proxy.noCurrentShader(null, null);
- return null; // no response in this case
- }
- }
- private String text;
- public MyMessage() { }
- public MyMessage(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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment