public void SetBlocktype(int x, int y, int z, Blocktype type) { if (y < 0 || y >= Chunk.Depth) { return; } Chunk chunk = GetChunkAt(x, z); if (chunk == null) { return; } x = (x % Chunk.Width + Chunk.Width) % Chunk.Width; z = (z % Chunk.Height + Chunk.Height) % Chunk.Height; chunk.SetBlocktype(x, y, z, type); chunk.Cached = false; if (x == Chunk.Width - 1 && chunk.Right != null) { chunk.Right.Cached = false; } if (x == 0 && chunk.Left != null) { chunk.Left.Cached = false; } if (z == Chunk.Height - 1 && chunk.Front != null) { chunk.Front.Cached = false; } if (z == 0 && chunk.Back != null) { chunk.Back.Cached = false; } }
public void RenderTransparent(bool cache) { if (_cached2 || (_displayList2.Cached && !cache)) { _displayList2.Call(); } else if (cache) { _displayList2.Begin(); GL.Begin(BeginMode.Quads); for (int x = 0; x < Width; ++x) { for (int y = 0; y < Depth; ++y) { for (int z = 0; z < Height; ++z) { Blocktype type = GetBlocktype(x, y, z); if (type != Blocktype.Water && type != Blocktype.StillWater && type != Blocktype.Ice) { continue; } BlocktypeInfo info = BlocktypeInfo.Find(type); BlockRenderer.Render(this, info, x, y, z); } } } GL.End(); _displayList2.End(); _cached2 = true; } }
private static void Main(string[] args) { Blocktype.Init(); ThreadPool.SetMaxThreads(20, 100); new Server(Console.Out).Start(args); Thread.Sleep(Timeout.Infinite); }
public BlocktypeInfo(Blocktype type, DrawMode drawMode) { Type = type; DrawMode = drawMode; Opaque = true; Size = Vector3.One; _blocktypes[(byte)type] = this; }
static string SafeLoad(string value, Blocktype oldvalue) { if (value == null) { return(oldvalue.ToString()); } return(value); }
public Block(Blocktype blocktype, bool demo = false) { InitializeComponent(); Type = blocktype; if (demo) { label1.Visible = false; label2.Visible = false; comboBox1.Visible = false; comboBox2.Visible = false; } }
public BreakOutBlock(int xPosition, int yPosition, int width, int height, Blocktype type) { _height = height; _width = width; _buffer = (width % 78) / 2; _xPosition = (xPosition * 78) + _buffer; _yPosition = (yPosition * 36) + _buffer + 36; _type = type; _rectSideList = new List<Rectangle> { new Rectangle(_xPosition + 1, _yPosition, 76, 1), new Rectangle(_xPosition + 77, _yPosition + 1, 1, 34), new Rectangle(_xPosition + 1, _yPosition + 35, 76, 1), new Rectangle(_xPosition, _yPosition + 1, 1, 34)}; }
public BreakOutBlock(int xPosition, int yPosition, int width, int height, Blocktype type) { _height = height; _width = width; _buffer = (width % 78) / 2; _xPosition = (xPosition * 78) + _buffer; _yPosition = (yPosition * 36) + _buffer + 36; _type = type; _rectSideList = new List <Rectangle> { new Rectangle(_xPosition + 1, _yPosition, 76, 1), new Rectangle(_xPosition + 77, _yPosition + 1, 1, 34), new Rectangle(_xPosition + 1, _yPosition + 35, 76, 1), new Rectangle(_xPosition, _yPosition + 1, 1, 34) }; }
public void RenderPicking(Vector3d origin, float range) { foreach (Chunk chunk in _chunks.Values) { double dist = Math.Sqrt((Math.Pow(origin.X - (chunk.X * Chunk.Width + Chunk.Width / 2), 2) + Math.Pow(origin.Z - (chunk.Z * Chunk.Height + Chunk.Height / 2), 2))) - Chunk.Width * Math.Sqrt(2) / 2; if (dist > range) { continue; } GL.PushMatrix(); GL.Translate(chunk.X * Chunk.Width, 0.0, chunk.Z * Chunk.Height); for (int x = (int)Math.Floor(Math.Max(0, origin.X - chunk.X * Chunk.Width - range)); x < (int)Math.Ceiling(Math.Min(Chunk.Width, origin.X - chunk.X * Chunk.Width + range)); x++) { GL.PushName(chunk.X * 16 + x); for (int y = (int)Math.Floor(Math.Max(0, origin.Y - range)); y < (int)Math.Ceiling(Math.Min(Chunk.Depth, origin.Y + range)); y++) { GL.PushName(y); for (int z = (int)Math.Floor(Math.Max(0, origin.Z - chunk.Z * Chunk.Height - range)); z < (int)Math.Ceiling(Math.Min(Chunk.Height, origin.Z - chunk.Z * Chunk.Height + range)); z++) { dist = Math.Sqrt((Math.Pow(origin.X - (chunk.X * Chunk.Width + x), 2) + Math.Pow(origin.Y - y, 2)) + Math.Pow(origin.Z - (chunk.Z * Chunk.Height + z), 2)); if (dist > range) { continue; } Blocktype type = chunk.GetBlocktype(x, y, z); if (type == Blocktype.Air) { continue; } BlocktypeInfo info = BlocktypeInfo.Find(type); GL.PushName(chunk.Z * 16 + z); BlockRenderer.RenderPicking(chunk, info, x, y, z); GL.PopName(); } GL.PopName(); } GL.PopName(); } GL.PopMatrix(); } }
private void SetType(Blocktype blocktype) { this.Type = blocktype; if (this.Type == Blocktype.Wait || this.Type == Blocktype.Goto || this.Type == Blocktype.Move || this.Type == Blocktype.Stop || this.Type == Blocktype.Disp) { comboBox2.Visible = false; label2.Visible = false; } // Set Labels and background color switch (this.Type) { case Blocktype.Move: labelBlockType.Text = "Rij"; label1.Text = "Snelheid:"; this.BackColor = Color.Green; break; case Blocktype.Turn: labelBlockType.Text = "Draai"; label1.Text = "Richting:"; label2.Text = "Graden:"; this.BackColor = Color.Aqua; break; case Blocktype.Stop: labelBlockType.Text = "Stop"; label1.Visible = false; comboBox1.Visible = false; this.BackColor = Color.Red; break; case Blocktype.Wait: labelBlockType.Text = "Wacht"; label1.Text = "Lengte (ms):"; this.BackColor = Color.Yellow; break; case Blocktype.Beep: labelBlockType.Text = "Beep"; label1.Text = "Toon:"; label2.Text = "Lengte (ms):"; this.BackColor = Color.BlueViolet; break; case Blocktype.Disp: labelBlockType.Text = "Scrijf"; label1.Text = "Tekst:"; this.BackColor = Color.LimeGreen; break; case Blocktype.Var: labelBlockType.Text = "Variabele"; label1.Text = "Variabele:"; label2.Text = "Waarde:"; this.BackColor = Color.Orange; break; case Blocktype.Add: labelBlockType.Text = "Plus"; label1.Text = "Variabele:"; label2.Text = "Waarde:"; this.BackColor = Color.Khaki; break; case Blocktype.Sub: labelBlockType.Text = "Min"; label1.Text = "Variabele:"; label2.Text = "Waarde:"; this.BackColor = Color.OrangeRed; break; case Blocktype.Goto: labelBlockType.Text = "Ga naar"; label1.Text = "Blok:"; this.BackColor = Color.Magenta; break; case Blocktype.GotoIf: labelBlockType.Text = "Ga naar als"; label1.Text = "Blok:"; label2.Text = "Conditie"; this.BackColor = Color.DarkMagenta; break; } // Set Combo Types and values switch (this.Type) { case Blocktype.Turn: comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; comboBox1.Items.AddRange(new string[] { "Rechts", "Links" }); comboBox1.Text = "Rechts"; break; case Blocktype.Beep: comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; comboBox1.Items.AddRange(new string[] { "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "G", "G#" }); comboBox1.Text = "C"; break; } }
public void SetBlocktype(int x, int y, int z, Blocktype type) { Blocks[GetIndex(x, y, z)] = (byte)type; }
public BlocktypeInfo(Blocktype type) : this(type, DrawMode.Block) { }
public static BlocktypeInfo Find(Blocktype type) { return(Find((byte)type)); }
internal void Init() { commands.Clear(); Create("info", "", "Displays information on the server.", delegate(Command command, Player player, string message) { if (message != "") { new Message("&eSyntax: " + command.syntax).Send(player); return; } new Message("&eCustom Minecraft server 'obsidian'.").Send(player); }); Create("help", "[<command>|commands]", "Displays generic help or information on a specific command.", delegate(Command command, Player player, string message) { if (message == "") { new Message(server.Help).Send(player); return; } command = this[message]; if (command == null) { new Message("&eThere is no help available for '" + message + "'.").Send(player); } else { new Message("&e" + command.help).Send(player); } }); Create("help commands", "", "Shows all available commands.", delegate(Command command, Player player, string message) { if (message != "") { new Message("&eSyntax: " + command.syntax).Send(player); return; } string cmds = ""; for (int i = 0; i < player.Group.Commands.Count; i += 1) { string cmd = player.Group.Commands[i].name; if (cmd.IndexOf(' ') != -1) { continue; } cmds += ", " + cmd; } cmds = cmds.Remove(0, 2); new Message("&eAvailable commands: " + cmds).Send(player); }); Create("bind", "<block> [<replace>]", "Replaces blocks built by a specific blocktype.", delegate(Command command, Player player, string message) { if (message == "") { new Message("&eSyntax: " + command.syntax).Send(player); return; } string[] args = message.Split(new char[1] { ' ' }, 2); Blocktype block = null; byte id; if (byte.TryParse(args[0], out id)) { block = Blocktype.FindById(id); } else { block = Blocktype.FindByName(args[0]); } if (block == null) { new Message("&eUnknown blocktype '" + args[0] + "'.").Send(player); return; } if (!block.Placeable) { new Message("&e" + block.Name + " is not placeable.").Send(player); return; } if (args.Length == 1) { if (player.bind[block.ID] == block.ID) { new Message("&e" + block.Name + " isn't bound.").Send(player); return; } player.bind[block.ID] = block.ID; new Message("&eUnbound " + block.Name + ".").Send(player); } else { Blocktype replace = null; if (byte.TryParse(args[1], out id)) { replace = Blocktype.FindById(id); } else { replace = Blocktype.FindByName(args[1]); } if (replace == null) { new Message("&eUnknown blocktype '" + args[1] + "'.").Send(player); return; } Node node = player.Group.Custom["bind"]; if (node == null || !node.Contains(replace.Name.ToLower())) { new Message("&eYou can't bind something to " + replace.Name + ".").Send(player); return; } if (player.bind[block.ID] == replace.ID) { new Message("&e" + block.Name + " is already bound to " + replace.Name + ".").Send(player); return; } player.bind[block.ID] = replace.ID; new Message("&eBound " + block.Name + " to " + replace.Name + ".").Send(player); } }); }
public static BlocktypeInfo Find(Blocktype type) { return Find((byte)type); }
public void SetType(Blocktype type) { _type = type; }