001    
002    /**
003     * BaseVehicle - Base class for interfacing boats and minecarts
004     * @author James
005     */
006    public class BaseVehicle extends BaseEntity {
007        /**
008         * Creptes an interface for a vehicle
009         * @param entity
010         */
011        public BaseVehicle(fe entity) {
012            this.entity = entity;
013        }
014    
015        /**
016         * Interface for vehicles.
017         */
018        public BaseVehicle() {
019        }
020    
021        /**
022         * Returns the x-motion of this vehicle
023         * @return x-motion
024         */
025        public double getMotionX() {
026            return entity.s;
027        }
028    
029        /**
030         * Returns the y-motion of this vehicle
031         * @return y-motion
032         */
033        public double getMotionY() {
034            return entity.t;
035        }
036    
037        /**
038         * Returns the z-motion of this vehicle
039         * @return z-motion
040         */
041        public double getMotionZ() {
042            return entity.u;
043        }
044    
045        /**
046         * Sets the x-motion of this vehicle
047         * @param motion motion to set
048         */
049        public void setMotionX(double motion) {
050            entity.s = motion;
051        }
052    
053        /**
054         * Sets the y-motion of this vehicle
055         * @param motion motion to set
056         */
057        public void setMotionY(double motion) {
058            entity.t = motion;
059        }
060    
061        /**
062         * Sets the z-motion of this vehicle
063         * @param motion motion to set
064         */
065        public void setMotionZ(double motion) {
066            entity.u = motion;
067        }
068    
069        /**
070         * Set vehicle motion
071         * @param motionX
072         * @param motionY
073         * @param motionZ
074         */
075        public void setMotion(double motionX, double motionY, double motionZ) {
076            entity.s = motionX;
077            entity.t = motionY;
078            entity.u = motionZ;
079        }
080    
081        /**
082         * Destroys this vehicle
083         */
084        public void destroy() {
085            entity.q();
086        }
087    
088        /**
089         * Checks if this vehicle is empty (unoccupied)
090         * @return true if unoccupied.
091         */
092        public boolean isEmpty() {
093            if (entity.j == null) {
094                return true;
095            } else {
096                return false;
097            }
098        }
099    
100        /**
101         * Returns the passenger. If there is no passenger this function returns null.
102         * @return passenger
103         */
104        public Player getPassenger() {
105            if (entity.j != null)
106                if (entity.j instanceof fy)
107                    return ((fy)entity.j).getPlayer();
108            return null;
109        }
110    }