Package com.flansmod.common.network

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

package com.flansmod.common.network;

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

import com.flansmod.common.driveables.EntityDriveable;
import com.flansmod.common.driveables.EntityVehicle;

public class PacketVehicleControl extends PacketDriveableControl
{
  public boolean doors;
 
  public PacketVehicleControl() {}

  public PacketVehicleControl(EntityDriveable driveable)
  {
    super(driveable);
    EntityVehicle vehicle = (EntityVehicle)driveable;
    doors = vehicle.varDoor;
  }
 
  @Override
  public void encodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
      super.encodeInto(ctx, data);
      data.writeBoolean(doors);
  }

  @Override
  public void decodeInto(ChannelHandlerContext ctx, ByteBuf data)
  {
    super.decodeInto(ctx, data);
    doors = data.readBoolean();
  }
 
  @Override
  protected void updateDriveable(EntityDriveable driveable, boolean clientSide)
  {
    super.updateDriveable(driveable, clientSide);
    EntityVehicle vehicle = (EntityVehicle)driveable;
    vehicle.varDoor = doors;
  }
}
TOP

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

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.