public void Use(Player p, string[] args) { string IsFlying = (string)p.ExtraData["IsFlying"]; if (IsFlying != null) { p.OnPlayerBigMove.Normal -= OnPlayerBigMove_Normal; p.OnPlayerBlockChange.Normal -= OnPlayerBlockChange_Normal; if (IsFlying == "+" && glassesFlatAndMiddle != null) { p.ResendBlockChange(glassesFlatAndMiddle, (Vector3S)p.ExtraData["FlyLastPos"]); } else if (IsFlying == "water" && fluidCube != null) { p.ResendBlockChange(fluidCube, (Vector3S)p.ExtraData["FlyLastPos"]); } else { p.ResendBlockChange(glassesFlat, (Vector3S)p.ExtraData["FlyLastPos"]); } p.ResendBlockChange(glassesFlat, (Vector3S)p.ExtraData["FlyLastPos"]); p.ExtraData["IsFlying"] = null; p.SendMessage(stopFlyMessage); return; } Vector3S belowBlock = p.belowBlock; if (args.Length > 0) { if (args[0] == "+" && glassesFlatAndMiddle != null) { p.ExtraData["IsFlying"] = "+"; p.SendBlockChangeWhereAir(glassesFlatAndMiddle, belowBlock, 20); p.ExtraData["FlyLastPos"] = belowBlock; } else if (args[0].ToLower() == "water" && fluidCube != null) { p.ExtraData["IsFlying"] = "water"; Vector3S tmp = belowBlock; tmp.y++; p.SendBlockChangeWhereAir(fluidCube, tmp, 9); p.ExtraData["FlyLastPos"] = tmp; } else { p.ExtraData["IsFlying"] = "normal"; p.SendBlockChangeWhereAir(glassesFlat, belowBlock, 20); p.ExtraData["FlyLastPos"] = belowBlock; } } else { p.ExtraData["IsFlying"] = "normal"; p.SendBlockChangeWhereAir(glassesFlat, belowBlock, 20); p.ExtraData["FlyLastPos"] = belowBlock; } p.OnPlayerBigMove.Normal += OnPlayerBigMove_Normal; p.OnPlayerBlockChange.Normal += OnPlayerBlockChange_Normal; p.SendMessage(startFlyMessage); }
public void Use(Player p, string[] args) { p.ExtraData.CreateIfNotExist("IsFlying", false); p.ExtraData["IsFlying"] = !(bool)p.ExtraData["IsFlying"]; if (!(bool)p.ExtraData["IsFlying"]) { p.OnPlayerBigMove.Normal -= OnPlayerBigMove_Normal; p.ResendBlockChange(glasses, (Vector3S)p.ExtraData["FlyLastPos"]); return; } p.SendBlockChangeWhereAir(glasses, p.belowBlock, 20); p.ExtraData["FlyLastPos"] = p.belowBlock; p.OnPlayerBigMove.Normal += OnPlayerBigMove_Normal; p.SendMessage("You are now flying. &cJump!"); }
void OnPlayerBigMove_Normal(Player sender, API.Events.MoveEventArgs args) { sender.ResendBlockChange(glasses, (Vector3S)sender.ExtraData["FlyLastPos"]); sender.ExtraData["FlyLastPos"] = sender.belowBlock; sender.SendBlockChangeWhereAir(glasses, sender.belowBlock, 20); }
void MoveGlass(Player sender) { if (sender.ExtraData["cursormoveglasslocked"] != null && (bool)sender.ExtraData["cursormoveglasslocked"]) return; lock (this) { sender.ExtraData["cursormovelocked"] = true; if (sender.ExtraData["CursorGlassCenter"] != null) { Vector3S old; if (sender.ExtraData["CursorGlassCenter"].GetType() == typeof(Vector3S)) old = (Vector3S)sender.ExtraData["CursorGlassCenter"]; else { old = new Vector3S(); old.FromString((string)sender.ExtraData["CursorGlassCenter"]); } sender.ResendBlockChange(surrounder, old); } Vector3S pos = new Vector3S((ushort)(sender.Pos.x / 32), (ushort)(sender.Pos.z / 32), (ushort)(sender.Pos.y / 32)); sender.SendBlockChange(surrounder, pos, 20); sender.ExtraData["CursorGlassCenter"] = pos; sender.ExtraData["cursormoveglasslocked"] = false; } }