public void TransferTags(NbtWriter writer) { writer.WriteBool("piglin_safe", this.Element.PiglinSafe); writer.WriteBool("natural", this.Element.Natural); writer.WriteFloat("ambient_light", this.Element.AmbientLight); if (this.Element.FixedTime.HasValue) { writer.WriteLong("fixed_time", this.Element.FixedTime.Value); } writer.WriteString("infiniburn", this.Element.Infiniburn); writer.WriteBool("respawn_anchor_works", this.Element.RespawnAnchorWorks); writer.WriteBool("has_skylight", this.Element.HasSkylight); writer.WriteBool("bed_works", this.Element.BedWorks); writer.WriteString("effects", this.Element.Effects); writer.WriteBool("has_raids", this.Element.HasRaids); writer.WriteInt("logical_height", this.Element.LogicalHeight); writer.WriteFloat("coordinate_scale", this.Element.CoordinateScale); writer.WriteBool("ultrawarm", this.Element.Ultrawarm); writer.WriteBool("has_ceiling", this.Element.HasCeiling); }
public async Task WriteSlotAsync(ItemStack slot) { if (slot is null) { slot = new ItemStack(0, 0) { Present = true } } ; var item = slot.GetItem(); await WriteBooleanAsync(slot.Present); if (slot.Present) { await WriteVarIntAsync(item.Id); await WriteByteAsync((sbyte)slot.Count); var writer = new NbtWriter(this, ""); var itemMeta = slot.ItemMeta; //TODO write enchants if (itemMeta.HasTags()) { writer.WriteBool("Unbreakable", itemMeta.Unbreakable); if (itemMeta.Durability > 0) { writer.WriteInt("Damage", itemMeta.Durability); } if (itemMeta.CustomModelData > 0) { writer.WriteInt("CustomModelData", itemMeta.CustomModelData); } if (itemMeta.CanDestroy != null) { writer.WriteListStart("CanDestroy", NbtTagType.String, itemMeta.CanDestroy.Count); foreach (var block in itemMeta.CanDestroy) { writer.WriteString(block); } writer.EndList(); } if (itemMeta.Name != null) { writer.WriteCompoundStart("display"); writer.WriteString("Name", new List <ChatMessage> { (ChatMessage)itemMeta.Name }.ToJson()); if (itemMeta.Lore != null) { writer.WriteListStart("Lore", NbtTagType.String, itemMeta.Lore.Count); foreach (var lore in itemMeta.Lore) { writer.WriteString(new List <ChatMessage> { (ChatMessage)lore }.ToJson()); } writer.EndList(); } writer.EndCompound(); } else if (itemMeta.Lore != null) { writer.WriteCompoundStart("display"); writer.WriteListStart("Lore", NbtTagType.String, itemMeta.Lore.Count); foreach (var lore in itemMeta.Lore) { writer.WriteString(new List <ChatMessage> { (ChatMessage)lore }.ToJson()); } writer.EndList(); writer.EndCompound(); } } writer.WriteString("id", item.UnlocalizedName); writer.WriteByte("Count", (byte)slot.Count); writer.EndCompound(); writer.TryFinish(); } }