public override TemplateObject Handle(TagData data) { if (data.Remaining == 0) { return this; } switch (data[0]) { // TODO: Mode, etc. // <--[tag] // @Name RecipeTag.input // @Group General Information // @ReturnType ListTag // @Returns the result of this recipe. // @Example "blocks/grass|blocks/dirt" .result returns "blocks/dirt|". // --> case "input": { ListTag list = new ListTag(); for (int i = 0; i < Internal.Input.Length; i++) { list.ListEntries.Add(new ItemTag(Internal.Input[i])); } return list.Handle(data.Shrink()); } default: return new TextTag(ToString()).Handle(data); } }
public PlayerInventory(Player player) : base(player, 36) { if (!player.NamedTag.Exist("Inventory")) { ListTag initItems = new ListTag("Inventory", NBTTagType.COMPOUND); for (int i = 0; i < this.Size; ++i) { initItems.Add(NBTIO.WriteItem(Item.Get(0, 0, 0), i)); } player.NamedTag.PutList(initItems); } ListTag items = player.NamedTag.GetList("Inventory"); for (int i = 0; i < this.Size; ++i) { Item item = NBTIO.ReadItem((CompoundTag)items[i]); this.SetItem(i, item, false); } this.PlayerCursorInventory = new PlayerCursorInventory(player); this.PlayerEnderChestInventory = new PlayerEnderChestInventory(player); this.CraftingGridInventory = new CraftingGridInventory(player); }
public override MixArticle ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { if (Id == 0) { Id = Repository.Max(c => c.Id, _context, _transaction).Data + 1; CreatedDateTime = DateTime.UtcNow; } if (Properties != null && Properties.Count > 0) { JArray arrProperties = new JArray(); foreach (var p in Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(p.Name)).OrderBy(p => p.Priority)) { arrProperties.Add(JObject.FromObject(p)); } ExtraProperties = arrProperties.ToString(Formatting.None); } Template = View != null?string.Format(@"{0}/{1}{2}", View.FolderType, View.FileName, View.Extension) : Template; if (ThumbnailFileStream != null) { string folder = CommonHelper.GetFullPath(new string[] { MixConstants.Folder.UploadFolder, "Articles", DateTime.UtcNow.ToString("dd-MM-yyyy") }); string filename = CommonHelper.GetRandomName(ThumbnailFileStream.Name); bool saveThumbnail = CommonHelper.SaveFileBase64(folder, filename, ThumbnailFileStream.Base64); if (saveThumbnail) { CommonHelper.RemoveFile(Thumbnail); Thumbnail = CommonHelper.GetFullPath(new string[] { folder, filename }); } } if (ImageFileStream != null) { string folder = CommonHelper.GetFullPath(new string[] { MixConstants.Folder.UploadFolder, "Articles", DateTime.UtcNow.ToString("dd-MM-yyyy") }); string filename = CommonHelper.GetRandomName(ImageFileStream.Name); bool saveImage = CommonHelper.SaveFileBase64(folder, filename, ImageFileStream.Base64); if (saveImage) { CommonHelper.RemoveFile(Image); Image = CommonHelper.GetFullPath(new string[] { folder, filename }); } } if (!string.IsNullOrEmpty(Image) && Image[0] == '/') { Image = Image.Substring(1); } if (!string.IsNullOrEmpty(Thumbnail) && Thumbnail[0] == '/') { Thumbnail = Thumbnail.Substring(1); } Tags = ListTag.ToString(Newtonsoft.Json.Formatting.None); GenerateSEO(); return(base.ParseModel(_context, _transaction)); }
/// <summary> /// <see cref="Entity"/> の初期化をします。 /// </summary> /// <param name="nbt"><see cref="Entity"/> のNBTデータ</param> protected virtual void EntityInit(CompoundTag nbt) { ListTag list = nbt.GetList("Pos"); this.X = ((FloatTag)list[0]).Data; this.Y = ((FloatTag)list[1]).Data; this.Z = ((FloatTag)list[2]).Data; list = nbt.GetList("Motion"); this.MotionX = ((FloatTag)list[0]).Data; this.MotionY = ((FloatTag)list[1]).Data; this.MotionZ = ((FloatTag)list[2]).Data; list = nbt.GetList("Rotation"); this.Yaw = ((FloatTag)list[0]).Data; this.Pitch = ((FloatTag)list[1]).Data; this.ResetLastMovements(); this.RecalculateBoundingBox(); this.DataProperties = new EntityMetadataManager(this.EntityID); this.SetDataProperty(new EntityDataLong(DATA_FLAGS, 0)); this.SetDataProperty(new EntityDataShort(DATA_AIR, 400)); this.SetDataProperty(new EntityDataShort(DATA_MAX_AIR, 400)); this.SetDataProperty(new EntityDataString(DATA_NAMETAG, "")); this.SetDataProperty(new EntityDataLong(DATA_LEAD_HOLDER_EID, -1)); this.SetDataProperty(new EntityDataFloat(DATA_SCALE, 1.0f)); this.SetDataProperty(new EntityDataFloat(DATA_BOUNDING_BOX_WIDTH, this.Width)); this.SetDataProperty(new EntityDataFloat(DATA_BOUNDING_BOX_HEIGHT, this.Height)); this.SetFlag(DATA_FLAGS, DATA_FLAG_HAS_COLLISION); this.SetFlag(DATA_FLAGS, DATA_FLAG_GRAVITY); this.Attributes = new EntityAttributeDictionary(this.EntityID); }
public Chunk NBTDeserialize(CompoundTag tag) { CompoundTag level = (CompoundTag)tag["Level"]; int x = level.GetInt("xPos"); int z = level.GetInt("zPos"); SubChunk[] subChunks = ArrayUtils.CreateArray <SubChunk>(16); ListTag sections = level.GetList("Sections"); for (int i = 0; i < sections.Count; ++i) { CompoundTag section = ((CompoundTag)sections[i]); SubChunk subChunk = new SubChunk(); byte y = section.GetByte("Y"); subChunk.BlockDatas = section.GetByteArray("Blocks"); subChunk.MetaDatas = new NibbleArray(section.GetByteArray("Data")); subChunk.SkyLights = new NibbleArray(section.GetByteArray("SkyLight")); subChunk.BlockLigths = new NibbleArray(section.GetByteArray("BlockLight")); subChunks[y] = subChunk; } byte[] biomes = level.GetByteArray("Biomes"); short[] cast = new short[256]; int[] heightMap = level.GetIntArray("HeightMap"); heightMap.CopyTo(cast, 0); Chunk chunk = new Chunk(x, z, subChunks, biomes, cast, level.GetList("Entities"), level.GetList("TileEntities")); chunk.LastUpdate = level.GetLong("LastUpdate"); chunk.InhabitedTime = level.GetLong("InhabitedTime"); chunk.LightPopulated = level.GetByte("LightPopulated") == 1; chunk.TerrainPopulated = level.GetByte("TerrainPopulated") == 1; return(chunk); }
private void BuildTree() { //NamedTag.Name = "Root"; Queue <NodeData> stack = new Queue <NodeData>(20); stack.Enqueue(new NodeData(treeView.Nodes, NamedTag)); while (stack.Count > 0) { NodeData current = stack.Dequeue(); TreeNodeCollection nodes = current.Nodes; Tag data = current.Tag; if (data is CompoundTag) { CompoundTag compound = (CompoundTag)data; TreeNode node = nodes.Add(current.ListIndex != -1 ? current.ListIndex + "" : (compound.Name == "" ? "<NoNameTag>" : compound.Name)); node.ToolTipText = compound.GetType().Name; foreach (Tag tag in compound.Tags.Values) { if (tag is CompoundTag || tag is ListTag) { stack.Enqueue(new NodeData(node.Nodes, tag)); } else { TreeNode child = node.Nodes.Add(tag.Name); child.ToolTipText = tag.GetType().Name; SetTagValue(child, tag); } } } else if (data is ListTag) { int index = 0; ListTag list = (ListTag)data; TreeNode node = nodes.Add(current.ListIndex != -1 ? current.ListIndex + "" : list.Name); node.ToolTipText = list.GetType().Name; foreach (Tag tag in list.Tags) { if (tag is CompoundTag || tag is ListTag) { stack.Enqueue(new NodeData(node.Nodes, tag, index)); } else { TreeNode child = node.Nodes.Add("" + index); child.ToolTipText = tag.GetType().Name; SetTagValue(child, tag); } index++; } } } }
public static RecipeMode ModeFor(ListTag modeinput) { if (modeinput.ListEntries.Count == 1 && modeinput.ListEntries[0].ToString().ToLowerFast() == "strict") { return RecipeMode.BOUND | RecipeMode.COLOR | RecipeMode.DATUM | RecipeMode.DESCRIPTION | RecipeMode.DISPLAY | RecipeMode.LOCAL | RecipeMode.MODEL | RecipeMode.SECONDARY | RecipeMode.SHARED | RecipeMode.TEXTURE | RecipeMode.TYPE | RecipeMode.WEIGHT | RecipeMode.VOLUME; } RecipeMode mode = 0; foreach (TemplateObject obj in modeinput.ListEntries) { RecipeMode adder; if (Enum.TryParse(obj.ToString().ToUpperInvariant(), out adder)) { mode |= adder; } } return mode; }
public void SetUp() { _listTag = new ListTag(); }
public override TemplateObject Handle(TagData data) { data.Shrink(); if (data.Remaining == 0) { return new TextTag(ToString()); } switch (data[0]) { // <--[tagbase] // @Name ServerTag.online_players // @Group Entities // @ReturnType ListTag // @Returns a list of all online players. // @Example .online_players could return "Fortifier|mcmonkey". // --> case "online_players": { ListTag players = new ListTag(); foreach (PlayerEntity p in TheServer.Players) { players.ListEntries.Add(new PlayerTag(p)); } return players.Handle(data.Shrink()); } // <--[tagbase] // @Name ServerTag.loaded_worlds // @Group World // @ReturnType ListTag // @Returns a list of all loaded worlds. // @Example .loaded_worlds could return "default|bob". // --> case "loaded_worlds": { ListTag worlds = new ListTag(); foreach (World w in TheServer.LoadedWorlds) { worlds.ListEntries.Add(new WorldTag(w)); } return worlds.Handle(data.Shrink()); } // <--[tagbase] // @Name ServerTag.loaded_recipes // @Group Items // @ReturnType ListTag // @Returns a list of all loaded recipes. // --> case "loaded_recipes": { ListTag recipes = new ListTag(); foreach (ItemRecipe r in TheServer.Recipes.Recipes) { recipes.ListEntries.Add(new RecipeTag(r)); } return recipes.Handle(data.Shrink()); } // <--[tagbase] // @Name ServerTag.can_craft_from[<ListTag>] // @Group Items // @ReturnType ListTag // @Returns a list of all loaded recipes that can be crafted from the given input. // @Example .can_craft_from[blocks/grass_forest] could return "1&pipeblocks/grass_forest|". // --> case "can_craft_from": { // TODO: Handle errors neatly! List<ItemStack> items = new List<ItemStack>(); ListTag list = ListTag.For(data.GetModifierObject(0)); foreach (TemplateObject obj in list.ListEntries) { items.Add(ItemTag.For(TheServer, obj).Internal); } ListTag recipes = new ListTag(); foreach (RecipeResult r in TheServer.Recipes.CanCraftFrom(items.ToArray())) { recipes.ListEntries.Add(new RecipeResultTag(r)); } return recipes.Handle(data.Shrink()); } // <--[tagbase] // @Name ServerTag.match_player[<TextTag>] // @Group Entities // @ReturnType PlayerTag // @Returns the player whose name best matches the input. // @Example .match_player[Fort] out of a group of "Fortifier", "Fort", and "Forty" would return "Fort". // @Example .match_player[monk] out of a group of "mcmonkey", "morph", and "Fort" would return "mcmonkey". // --> case "match_player": { string pname = data.GetModifier(0); PlayerEntity player = TheServer.GetPlayerFor(pname); if (player == null) { data.Error("Invalid player '" + TagParser.Escape(pname) + "'!"); return new NullTag(); } return new PlayerTag(player).Handle(data.Shrink()); } default: return new TextTag(ToString()).Handle(data); } }
public override TemplateObject Handle(TagData data) { if (data.Remaining == 0) { return this; } switch (data[0]) { // <--[tag] // @Name RecipeResultTag.recipe // @Group General Information // @ReturnType RecipeTag // @Returns the original recipe used to form this recipe result. // --> case "recipe": return new RecipeTag(Internal.Recipe).Handle(data.Shrink()); // <--[tag] // @Name RecipeResultTag.used_input // @Group General Information // @ReturnType ListTag // @Returns the input items used by this recipe result. // @Example "1|blocks/grass|blocks/dirt" .result returns "blocks/grass|blocks/dirt|". // --> case "used_input": { ListTag list = new ListTag(); for (int i = 0; i < Internal.UsedInput.Count; i++) { list.ListEntries.Add(new ItemTag(Internal.UsedInput[i])); } return list.Handle(data.Shrink()); } default: return new TextTag(ToString()).Handle(data); } }
public override string ToString() { ListTag list = new ListTag(); list.ListEntries.Add(new IntegerTag(Internal.Recipe.Index)); foreach (ItemStack item in Internal.UsedInput) { list.ListEntries.Add(new ItemTag(item)); } return list.ToString(); }
void AddHashPoint(string file, Point p) { var lf = new ListTag(file); if (!itemlist.ContainsKey(lf.hash)) itemlist[lf.hash] = new Dictionary<string, Point>(); itemlist[lf.hash][lf.hash_uniq] = p; lstTags.Items.Add(lf); }