Skip to content

Commit

Permalink
thank you mojang
Browse files Browse the repository at this point in the history
  • Loading branch information
Tides committed Dec 19, 2023
1 parent e077a6d commit 6605569
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
15 changes: 10 additions & 5 deletions Obsidian.Nbt/NbtTag.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Obsidian.Nbt;

public class NbtTag<T> : INbtTag
public sealed class NbtTag<T> : INbtTag
{
public NbtTagType Type { get; }

Expand All @@ -11,13 +11,18 @@ public class NbtTag<T> : INbtTag
/// </summary>
public INbtTag Parent { get; set; }

public T Value { get; }
public T? Value { get; }

public NbtTag(string name, T value, INbtTag parent = null)
public NbtTag(string name, T? value, INbtTag parent = null)
{
this.Name = name;
this.Parent = parent;
this.Value = value;

//Some structure files from minecraft have properties with names but null values???
if (value is null)
return;

this.Type = value switch
{
bool => NbtTagType.Byte,
Expand Down Expand Up @@ -45,7 +50,7 @@ public override string ToString()
case NbtTagType.String:
return $"TAG_{this.Type}('{this.Name}'): {this.Value}";
default:
throw new NotSupportedException("Only generic types are supported.");
return string.Empty;
}
}

Expand All @@ -65,7 +70,7 @@ public string PrettyString(int depth = 2, int addBraceDepth = 1)
return name.PadLeft(name.Length + depth);
}
default:
throw new NotSupportedException("Only generic types are supported.");
return string.Empty;
}
}
}
Expand Down
33 changes: 17 additions & 16 deletions Obsidian.Nbt/Obsidian.Nbt.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>annotations</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>

0 comments on commit 6605569

Please sign in to comment.