Package com.flansmod.common.network

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

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.EntitySeat;
import com.flansmod.common.driveables.EnumDriveablePart;

public class PacketRepairDriveable extends PacketBase
{
  public String shortName; 
 
  public PacketRepairDriveable() {}

  public PacketRepairDriveable(EnumDriveablePart part)
  {
    shortName = part.getShortName();
  }
 
  @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)
  {
    EnumDriveablePart part = EnumDriveablePart.getPart(shortName);  
    //Try to repair the driveable
    FlansMod.proxy.repairDriveable(playerEntity, ((EntitySeat)playerEntity.ridingEntity).driveable, ((EntitySeat)playerEntity.ridingEntity).driveable.getDriveableData().parts.get(part));
  }

  @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.PacketRepairDriveable

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.