public CommandBlockFlags GetDataFlags(bool alwaysOn = false) { // Make a copy CommandBlockFlags retFlags = _flags; if (alwaysOn) { retFlags |= CommandBlockFlags.AlwaysOn; } return(retFlags); }
public void SetCommandBlockType(CommandBlockFlags type) { _flags &= ~(CommandBlockFlags.Impulse | CommandBlockFlags.Chain | CommandBlockFlags.Repeat); switch (type) { case CommandBlockFlags.Repeat: case CommandBlockFlags.Chain: case CommandBlockFlags.Impulse: _flags |= type; break; default: throw new ArgumentException("Flags variables are not supported when setting the command block type."); } }
/// <summary> /// Writes a single command block to a structure file at the given path. /// </summary> /// <param name="filePath">The path to the location at which the NBT structure file will be saved.</param> /// <param name="command">The command to put inside the single command block in the structure.</param> /// <param name="properties">The properties of the single command block in the structure.</param> /// <param name="dir">The direction in which the command block will be facing.</param> public void WriteCommandBlockToStructure(string filePath, string command, CommandBlockFlags properties, CommandBlockDirection dir) { NbtFile file = new NbtFile(); file.RootTag = new NbtCompound("") { new NbtList("size") { // X, Y, Z new NbtInt(32), new NbtInt(32), new NbtInt(32) }, //new NbtList("entities") { }, new NbtList("palette") { GetPaletteSignature(CommandBlockInfo.FromEnums(properties, dir)) }, new NbtList("blocks") { new NbtCompound() { new NbtCompound("nbt") { new NbtByte("auto", Convert.ToByte(properties.HasFlag(CommandBlockFlags.AlwaysOn))), new NbtString("Command", command), new NbtString("id", "Control"), new NbtString("CustomName", "@"), new NbtByte("TrackOutput", 0), new NbtByte("powered", 0), new NbtByte("conditionMet", 1), new NbtInt("SuccessCount", 0) }, new NbtList("pos") { new NbtInt(0), new NbtInt(0), new NbtInt(0) }, new NbtInt("state", 0) } }, new NbtString("author", "MCCBL Compiler"), new NbtInt("version", 1) }; file.SaveToFile(filePath, NbtCompression.GZip); }
public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags) { return(false); //Currently not implemented }
private CommandBlockInfo(CommandBlockFlags flags, CommandBlockDirection dir) { _facingDirection = dir; _flags = flags & ~(CommandBlockFlags.AlwaysOn | CommandBlockFlags.Chain | CommandBlockFlags.Impulse | CommandBlockFlags.Repeat); SetCommandBlockType(flags & (CommandBlockFlags.Chain | CommandBlockFlags.Impulse | CommandBlockFlags.Repeat)); }
public static CommandBlockInfo FromEnums(CommandBlockFlags flags, CommandBlockDirection dir) { return(new CommandBlockInfo(flags, dir)); }