/// <summary> /// Move less than four blocks to the given destination and rotate. /// </summary> /// <param name="x">The X coordinate of the target.</param> /// <param name="y">The Y coordinate of the target.</param> /// <param name="z">The Z coordinate of the target.</param> /// <param name="yaw">The absolute yaw to which entity should change.</param> /// <param name="pitch">The absolute pitch to which entity should change.</param> public virtual void MoveTo(AbsWorldCoords absCoords, float yaw, float pitch) { //Vector3 newPosition = new Vector3(absCoords.X, absCoords.Y, absCoords.Z); AbsWorldCoords newPosition = absCoords; //Event EntityMoveEventArgs e = new EntityMoveEventArgs(this, newPosition, Position); Server.PluginManager.CallEvent(Event.EntityMove, e); if (e.EventCanceled) { return; } newPosition = e.NewPosition; //End Event sbyte oldPacketPosX = (sbyte)Math.Floor(Position.X * 32.0); sbyte oldPacketPosY = (sbyte)Math.Floor(Position.Y * 32.0); sbyte oldPacketPosZ = (sbyte)Math.Floor(Position.Z * 32.0); sbyte newPacketPosX = (sbyte)Math.Floor(newPosition.X * 32.0); sbyte newPacketPosY = (sbyte)Math.Floor(newPosition.Y * 32.0); sbyte newPacketPosZ = (sbyte)Math.Floor(newPosition.Z * 32.0); sbyte dx = (sbyte)(newPacketPosX - oldPacketPosX); sbyte dy = (sbyte)(newPacketPosY - oldPacketPosY); sbyte dz = (sbyte)(newPacketPosZ - oldPacketPosZ); Position = newPosition; this.Yaw = yaw; this.Pitch = pitch; OnMoveRotateTo(dx, dy, dz); }
protected virtual void OnPositionChanged(EntityMoveEventArgs e) { if (PositionChanged != null) { PositionChanged(this, e); } }
/// <summary> /// Move less than four blocks to the given destination and update all affected clients. /// </summary> /// <param name="x">The X coordinate of the target.</param> /// <param name="y">The Y coordinate of the target.</param> /// <param name="z">The Z coordinate of the target.</param> public virtual void MoveTo(AbsWorldCoords absCoords) { AbsWorldCoords newPosition = absCoords; //Event EntityMoveEventArgs e = new EntityMoveEventArgs(this, newPosition, Position); Server.PluginManager.CallEvent(Event.EntityMove, e); if (e.EventCanceled) { return; } newPosition = e.NewPosition; //End Event sbyte oldPacketPosX = (sbyte)Math.Floor(Position.X * 32.0); sbyte oldPacketPosY = (sbyte)Math.Floor(Position.Y * 32.0); sbyte oldPacketPosZ = (sbyte)Math.Floor(Position.Z * 32.0); sbyte newPacketPosX = (sbyte)Math.Floor(newPosition.X * 32.0); sbyte newPacketPosY = (sbyte)Math.Floor(newPosition.Y * 32.0); sbyte newPacketPosZ = (sbyte)Math.Floor(newPosition.Z * 32.0); sbyte dx = (sbyte)(newPacketPosX - oldPacketPosX); sbyte dy = (sbyte)(newPacketPosY - oldPacketPosY); sbyte dz = (sbyte)(newPacketPosZ - oldPacketPosZ); Position = newPosition; // TODO: this doesn't prevent changing the Position by more than 4 blocks OnMoveTo(dx, dy, dz); }
void EntityPositionChanged(object sender, EntityMoveEventArgs e) { OnPositionChanged(new ServerDynamicEntityMoveEventArgs { ServerDynamicEntity = this, PreviousPosition = e.PreviousPosition }); }
private void PlayerEntityPositionChanged(object sender, EntityMoveEventArgs e) { _server.ServerConnection.Send(new EntityPositionMessage { Position = e.Entity.Position, EntityId = e.Entity.DynamicId }); }
private void OnEntityMoved(EntityMoveEventArgs e) { var handler = EntityMoved; if (handler != null) { handler(this, e); } }
private void OnMove(EntityMoveEventArgs e) { foreach (EventListener el in Plugins) { if (el.Event == Event.EntityMove) { IEntityListener l = el.Listener as IEntityListener; l.OnMove(e); } } }
public void OnMove(EntityMoveEventArgs e) { }