Last active
October 18, 2016 01:02
-
-
Save matshou/cbb718033a0334c67265bb1c12b88c54 to your computer and use it in GitHub Desktop.
Example: Packet handler as an outer class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.padwolf.minecraft.t1d.packets; | |
import com.padwolf.minecraft.t1d.refs.Functions; | |
import cpw.mods.fml.common.network.simpleimpl.IMessage; | |
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; | |
import cpw.mods.fml.common.network.simpleimpl.MessageContext; | |
public class MessagePacketHandler implements IMessageHandler<MessagePacket, IMessage> | |
{ | |
public MessagePacketHandler() {} | |
@Override | |
public IMessage onMessage(MessagePacket message, MessageContext ctx) | |
{ | |
Functions.sendChatMessage(ctx.getServerHandler().playerEntity, String.format("Received %s from %s", message.data, ctx.getServerHandler().playerEntity.getDisplayName())); | |
return null; // no response in this case | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment