Skip to content

Commit bfb0fda

Browse files
committed
fix items
1 parent 1255a74 commit bfb0fda

File tree

5 files changed

+3609
-1791
lines changed

5 files changed

+3609
-1791
lines changed

src/MiNET/MiNET.Console/minet.zip

5.09 KB
Binary file not shown.

src/MiNET/MiNET/CertificateData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public class ExtraData
108108
public string Xuid { get; set; }
109109

110110
public string TitleId { get; set; }
111+
public string SandboxId { get; set; }
111112
}
112113

113114
public class NewtonsoftMapper : IJsonMapper

src/MiNET/MiNET/Net/Packet.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,13 +2146,25 @@ public Itemstates ReadItemstates()
21462146
var version = ReadVarInt();
21472147
var components = ReadNbt();
21482148

2149+
byte[] componentValue = new byte[0];
2150+
2151+
if (component && components.NbtFile.RootTag["components"] != null)
2152+
{
2153+
using (MemoryStream stream = new MemoryStream())
2154+
{
2155+
NbtFile file = new NbtFile(components.NbtFile.RootTag["components"] as NbtCompound);
2156+
file.SaveToStream(stream, NbtCompression.None);
2157+
componentValue = stream.ToArray();
2158+
}
2159+
}
2160+
21492161
result.Add(new Itemstate
21502162
{
21512163
Id = legacyId,
21522164
Name = name,
21532165
ComponentBased = component,
21542166
Version = version,
2155-
//Components = component ? SerializeNbtCompound(components.NbtFile) : null
2167+
Components = componentValue
21562168
});
21572169
}
21582170

@@ -2177,15 +2189,29 @@ public void Write(Itemstates itemstates)
21772189
Write(itemstate.Id);
21782190
Write(itemstate.ComponentBased);
21792191
WriteVarInt(itemstate.Version);
2180-
Write(new Nbt
2192+
Nbt nbt = new Nbt
21812193
{
21822194
NbtFile = new NbtFile
21832195
{
21842196
BigEndian = false,
21852197
UseVarInt = true,
21862198
RootTag = new NbtCompound("")
21872199
}
2188-
});
2200+
};
2201+
if (itemstate.ComponentBased && itemstate.Components.Count() > 0)
2202+
{
2203+
using (MemoryStream stream = new MemoryStream(itemstate.Components))
2204+
{
2205+
NbtFile file = new NbtFile();
2206+
file.LoadFromStream(stream, NbtCompression.None);
2207+
var componentNbt = new NbtCompound("")
2208+
{
2209+
file.RootTag as NbtCompound
2210+
};
2211+
nbt.NbtFile.RootTag = componentNbt;
2212+
}
2213+
}
2214+
Write(nbt);
21892215
}
21902216
}
21912217

src/MiNET/MiNET/PlayerAttributes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,8 @@ public class Itemstate
9696

9797
[JsonProperty("version")]
9898
public int Version { get; set; }
99+
100+
[JsonProperty("components")]
101+
public byte[] Components { get; set; }
99102
}
100103
}

0 commit comments

Comments
 (0)