Package net.minecraft.nbt
Class NbtIo
java.lang.Object
net.minecraft.nbt.NbtIo
A set of utility functions for reading, writing, and scanning NBT files.
Methods that do not require
NbtTagSizeTracker
accept any bytes of data,
provided that its depth does not exceed 512.- Mappings:
Namespace Name official rh
intermediary net/minecraft/class_2507
named net/minecraft/nbt/NbtIo
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static DataInputStream
decompress
(InputStream stream) Returns a new input stream that decompresses the inputstream
.static NbtElement
read
(DataInput input, NbtTagSizeTracker tracker) Reads an NBT element frominput
.static @Nullable NbtCompound
Reads an NBT compound fromfile
.static NbtCompound
readCompound
(DataInput input) Reads an NBT compound frominput
.static NbtCompound
readCompound
(DataInput input, NbtTagSizeTracker tracker) Reads an NBT compound frominput
.static NbtCompound
readCompressed
(File file) Reads an NBT compound from Gzip-compressedfile
.static NbtCompound
readCompressed
(InputStream stream) Reads an NBT compound from Gzip-compressedstream
.private static NbtElement
readElement
(DataInput input, NbtTagSizeTracker tracker) private static NbtElement
readElement
(DataInput input, NbtTagSizeTracker tracker, byte typeId) static void
scan
(DataInput input, NbtScanner scanner, NbtTagSizeTracker tracker) Scans the NBT input usingscanner
.static void
scanCompressed
(File file, NbtScanner scanner, NbtTagSizeTracker tracker) Scans the compressed NBT file usingscanner
.static void
scanCompressed
(InputStream stream, NbtScanner scanner, NbtTagSizeTracker tracker) Scans the compressed NBT stream usingscanner
.static void
write
(NbtCompound nbt, File file) Writes thenbt
tofile
.static void
write
(NbtElement nbt, DataOutput output) Writes thenbt
tooutput
.static void
writeCompound
(NbtCompound nbt, DataOutput output) Writes thenbt
tooutput
.static void
writeCompressed
(NbtCompound nbt, File file) Writes the Gzip-compressednbt
tofile
.static void
writeCompressed
(NbtCompound nbt, OutputStream stream) Writes the Gzip-compressednbt
tostream
.static void
writeForPacket
(NbtElement nbt, DataOutput output) Writes thenbt
tooutput
.
-
Constructor Details
-
NbtIo
public NbtIo()
-
-
Method Details
-
readCompressed
Reads an NBT compound from Gzip-compressedfile
.- Returns:
- the NBT compound from the file
- Throws:
IOException
- if the IO operation fails or if the root NBT element is not a compoundNbtSizeValidationException
- if the NBT is too deep- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/File;)Lqw;
intermediary method_30613
Lnet/minecraft/class_2507;method_30613(Ljava/io/File;)Lnet/minecraft/class_2487;
named readCompressed
Lnet/minecraft/nbt/NbtIo;readCompressed(Ljava/io/File;)Lnet/minecraft/nbt/NbtCompound;
-
decompress
Returns a new input stream that decompresses the inputstream
.- Returns:
- a new input stream that decompresses the input
stream
- Throws:
IOException
- Mappings:
Namespace Name Mixin selector official b
Lrh;b(Ljava/io/InputStream;)Ljava/io/DataInputStream;
intermediary method_40059
Lnet/minecraft/class_2507;method_40059(Ljava/io/InputStream;)Ljava/io/DataInputStream;
named decompress
Lnet/minecraft/nbt/NbtIo;decompress(Ljava/io/InputStream;)Ljava/io/DataInputStream;
-
readCompressed
Reads an NBT compound from Gzip-compressedstream
.- Returns:
- the NBT compound from the stream
- Throws:
IOException
- if the IO operation fails or if the root NBT element is not a compoundNbtSizeValidationException
- if the NBT is too deep- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/InputStream;)Lqw;
intermediary method_10629
Lnet/minecraft/class_2507;method_10629(Ljava/io/InputStream;)Lnet/minecraft/class_2487;
named readCompressed
Lnet/minecraft/nbt/NbtIo;readCompressed(Ljava/io/InputStream;)Lnet/minecraft/nbt/NbtCompound;
-
scanCompressed
public static void scanCompressed(File file, NbtScanner scanner, NbtTagSizeTracker tracker) throws IOException Scans the compressed NBT file usingscanner
.- Throws:
IOException
- if the IO operation failsNbtSizeValidationException
- if thetracker
's validation fails- See Also:
- API Note:
- This method does not return the scan result; the user is expected
to call the appropriate method of the
NbtScanner
subclasses, such asNbtCollector.getRoot()
. - Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/File;Lrn;Lrf;)V
intermediary method_40057
Lnet/minecraft/class_2507;method_40057(Ljava/io/File;Lnet/minecraft/class_6836;Lnet/minecraft/class_2505;)V
named scanCompressed
Lnet/minecraft/nbt/NbtIo;scanCompressed(Ljava/io/File;Lnet/minecraft/nbt/scanner/NbtScanner;Lnet/minecraft/nbt/NbtTagSizeTracker;)V
-
scanCompressed
public static void scanCompressed(InputStream stream, NbtScanner scanner, NbtTagSizeTracker tracker) throws IOException Scans the compressed NBT stream usingscanner
.- Throws:
IOException
- if the IO operation failsNbtSizeValidationException
- if thetracker
's validation fails- See Also:
- API Note:
- This method does not return the scan result; the user is expected
to call the appropriate method of the
NbtScanner
subclasses, such asNbtCollector.getRoot()
. - Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/InputStream;Lrn;Lrf;)V
intermediary method_40058
Lnet/minecraft/class_2507;method_40058(Ljava/io/InputStream;Lnet/minecraft/class_6836;Lnet/minecraft/class_2505;)V
named scanCompressed
Lnet/minecraft/nbt/NbtIo;scanCompressed(Ljava/io/InputStream;Lnet/minecraft/nbt/scanner/NbtScanner;Lnet/minecraft/nbt/NbtTagSizeTracker;)V
-
writeCompressed
Writes the Gzip-compressednbt
tofile
.- Throws:
IOException
- if the IO operation fails- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Lqw;Ljava/io/File;)V
intermediary method_30614
Lnet/minecraft/class_2507;method_30614(Lnet/minecraft/class_2487;Ljava/io/File;)V
named writeCompressed
Lnet/minecraft/nbt/NbtIo;writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/io/File;)V
-
writeCompressed
Writes the Gzip-compressednbt
tostream
.- Throws:
IOException
- if the IO operation fails- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Lqw;Ljava/io/OutputStream;)V
intermediary method_10634
Lnet/minecraft/class_2507;method_10634(Lnet/minecraft/class_2487;Ljava/io/OutputStream;)V
named writeCompressed
Lnet/minecraft/nbt/NbtIo;writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/io/OutputStream;)V
-
write
Writes thenbt
tofile
.- Throws:
IOException
- if the IO operation fails- See Also:
- Mappings:
Namespace Name Mixin selector official b
Lrh;b(Lqw;Ljava/io/File;)V
intermediary method_10630
Lnet/minecraft/class_2507;method_10630(Lnet/minecraft/class_2487;Ljava/io/File;)V
named write
Lnet/minecraft/nbt/NbtIo;write(Lnet/minecraft/nbt/NbtCompound;Ljava/io/File;)V
-
read
Reads an NBT compound fromfile
.- Returns:
- the NBT compound from the file, or
null
if the file does not exist - Throws:
IOException
- if the IO operation fails or if the root NBT element is not a compoundNbtSizeValidationException
- if the NBT is too deep- Mappings:
Namespace Name Mixin selector official b
Lrh;b(Ljava/io/File;)Lqw;
intermediary method_10633
Lnet/minecraft/class_2507;method_10633(Ljava/io/File;)Lnet/minecraft/class_2487;
named read
Lnet/minecraft/nbt/NbtIo;read(Ljava/io/File;)Lnet/minecraft/nbt/NbtCompound;
-
readCompound
Reads an NBT compound frominput
.- Returns:
- the NBT compound from the input
- Throws:
IOException
- if the IO operation fails or if the root NBT element is not a compoundNbtSizeValidationException
- if the NBT is too deep- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/DataInput;)Lqw;
intermediary method_10627
Lnet/minecraft/class_2507;method_10627(Ljava/io/DataInput;)Lnet/minecraft/class_2487;
named readCompound
Lnet/minecraft/nbt/NbtIo;readCompound(Ljava/io/DataInput;)Lnet/minecraft/nbt/NbtCompound;
-
readCompound
public static NbtCompound readCompound(DataInput input, NbtTagSizeTracker tracker) throws IOException Reads an NBT compound frominput
.- Returns:
- the NBT compound from the input
- Throws:
IOException
- if the IO operation fails or if the root NBT element is not a compoundNbtSizeValidationException
- if thetracker
's validation fails- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/DataInput;Lrf;)Lqw;
intermediary method_10625
Lnet/minecraft/class_2507;method_10625(Ljava/io/DataInput;Lnet/minecraft/class_2505;)Lnet/minecraft/class_2487;
named readCompound
Lnet/minecraft/nbt/NbtIo;readCompound(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;
-
writeCompound
Writes thenbt
tooutput
.- Throws:
IOException
- if the IO operation fails- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Lqw;Ljava/io/DataOutput;)V
intermediary method_10628
Lnet/minecraft/class_2507;method_10628(Lnet/minecraft/class_2487;Ljava/io/DataOutput;)V
named writeCompound
Lnet/minecraft/nbt/NbtIo;writeCompound(Lnet/minecraft/nbt/NbtCompound;Ljava/io/DataOutput;)V
-
scan
public static void scan(DataInput input, NbtScanner scanner, NbtTagSizeTracker tracker) throws IOException Scans the NBT input usingscanner
.- Throws:
IOException
- if the IO operation failsNbtSizeValidationException
- if thetracker
's validation fails- API Note:
- This method does not return the scan result; the user is expected
to call the appropriate method of the
NbtScanner
subclasses, such asNbtCollector.getRoot()
. - Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/DataInput;Lrn;Lrf;)V
intermediary method_39855
Lnet/minecraft/class_2507;method_39855(Ljava/io/DataInput;Lnet/minecraft/class_6836;Lnet/minecraft/class_2505;)V
named scan
Lnet/minecraft/nbt/NbtIo;scan(Ljava/io/DataInput;Lnet/minecraft/nbt/scanner/NbtScanner;Lnet/minecraft/nbt/NbtTagSizeTracker;)V
-
read
Reads an NBT element frominput
. UnlikereadCompound(DataInput, NbtTagSizeTracker)
, the element does not have to be a compound.- Returns:
- the NBT element from the input
- Throws:
IOException
- if the IO operation failsNbtSizeValidationException
- if thetracker
's validation fails- Mappings:
Namespace Name Mixin selector official b
Lrh;b(Ljava/io/DataInput;Lrf;)Lrq;
intermediary method_52894
Lnet/minecraft/class_2507;method_52894(Ljava/io/DataInput;Lnet/minecraft/class_2505;)Lnet/minecraft/class_2520;
named read
Lnet/minecraft/nbt/NbtIo;read(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;
-
writeForPacket
Writes thenbt
tooutput
. The output is the byte indicating the element type, followed by the NBT data.- Throws:
IOException
- if the IO operation fails- See Also:
- API Note:
- In vanilla, this is used exclusively in networking.
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Lrq;Ljava/io/DataOutput;)V
intermediary method_52893
Lnet/minecraft/class_2507;method_52893(Lnet/minecraft/class_2520;Ljava/io/DataOutput;)V
named writeForPacket
Lnet/minecraft/nbt/NbtIo;writeForPacket(Lnet/minecraft/nbt/NbtElement;Ljava/io/DataOutput;)V
-
write
Writes thenbt
tooutput
. The output is the byte indicating the element type, followed by an empty string and the NBT data.- Throws:
IOException
- if the IO operation fails- See Also:
- Mappings:
Namespace Name Mixin selector official b
Lrh;b(Lrq;Ljava/io/DataOutput;)V
intermediary method_10631
Lnet/minecraft/class_2507;method_10631(Lnet/minecraft/class_2520;Ljava/io/DataOutput;)V
named write
Lnet/minecraft/nbt/NbtIo;write(Lnet/minecraft/nbt/NbtElement;Ljava/io/DataOutput;)V
-
readElement
private static NbtElement readElement(DataInput input, NbtTagSizeTracker tracker) throws IOException - Throws:
IOException
- Mappings:
Namespace Name Mixin selector official c
Lrh;c(Ljava/io/DataInput;Lrf;)Lrq;
intermediary method_10626
Lnet/minecraft/class_2507;method_10626(Ljava/io/DataInput;Lnet/minecraft/class_2505;)Lnet/minecraft/class_2520;
named readElement
Lnet/minecraft/nbt/NbtIo;readElement(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;
-
readElement
- Mappings:
Namespace Name Mixin selector official a
Lrh;a(Ljava/io/DataInput;Lrf;B)Lrq;
intermediary method_52892
Lnet/minecraft/class_2507;method_52892(Ljava/io/DataInput;Lnet/minecraft/class_2505;B)Lnet/minecraft/class_2520;
named readElement
Lnet/minecraft/nbt/NbtIo;readElement(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;B)Lnet/minecraft/nbt/NbtElement;
-