Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.plaigon.plaig4sounds.common.packet;
- import io.netty.buffer.ByteBuf;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.player.EntityPlayerMP;
- 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 cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class PacketPLS implements IMessage
- {
- private String fileName;
- public PacketPLS()
- {
- }
- public PacketPLS(String fileName)
- {
- this.fileName = fileName;
- }
- @Override
- public void fromBytes(ByteBuf buf)
- {
- // this.fileName = ByteBufUtils.readUTF8String(buf);
- System.out.println(ByteBufUtils.readUTF8String(buf));
- }
- @Override
- public void toBytes(ByteBuf buf)
- {
- ByteBufUtils.writeUTF8String(buf, fileName);
- }
- public static class Handler implements IMessageHandler<PacketPLS, IMessage>
- {
- @SideOnly(Side.CLIENT)
- @Override
- public IMessage onMessage(PacketPLS message, MessageContext ctx)
- {
- System.out.println("string: " + message.fileName);
- Minecraft.getMinecraft().thePlayer.sendChatMessage("well received on client side, with string: " + message.fileName);//The string is null in game
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement