Package com.flansmod.common.network

Source Code of com.flansmod.common.network.PacketCraftDriveable

package com.flansmod.common.network;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import com.flansmod.common.FlansMod;
import com.flansmod.common.driveables.DriveableType;

public class PacketCraftDriveable extends PacketBase
{
  public String shortName; 
 
  public PacketCraftDriveable() {}
 
  public PacketCraftDriveable(String s)
  {
    shortName = s;
  }
 
  @Override
  public void encodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
    writeUTF(data, shortName);
  }

  @Override
  public void decodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
    shortName = readUTF(data);
  }

  @Override
  public void handleServerSide(EntityPlayerMP playerEntity)
  {
    DriveableType type = DriveableType.getDriveable(shortName);  
    //Try to craft the driveable
    FlansMod.proxy.craftDriveable(playerEntity, type);
  }

  @Override
  @SideOnly(Side.CLIENT)
  public void handleClientSide(EntityPlayer clientPlayer)
  {
    FlansMod.log("Received driveable repair packet on client side. Skipping.");
  }
}
TOP

Related Classes of com.flansmod.common.network.PacketCraftDriveable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.