diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/nbt/NbtIo.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/nbt/NbtIo.java.patch | 473 |
1 files changed, 473 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/nbt/NbtIo.java.patch b/patch-remap/mache-vineflower/net/minecraft/nbt/NbtIo.java.patch new file mode 100644 index 0000000000..fae3c9ea36 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/nbt/NbtIo.java.patch @@ -0,0 +1,473 @@ +--- a/net/minecraft/nbt/NbtIo.java ++++ b/net/minecraft/nbt/NbtIo.java +@@ -1,3 +1,4 @@ ++// mc-dev import + package net.minecraft.nbt; + + import java.io.BufferedOutputStream; +@@ -10,6 +11,7 @@ + import java.io.OutputStream; + import java.io.UTFDataFormatException; + import java.nio.file.Files; ++import java.nio.file.LinkOption; + import java.nio.file.OpenOption; + import java.nio.file.Path; + import java.nio.file.StandardOpenOption; +@@ -23,87 +25,270 @@ + import net.minecraft.util.FastBufferedInputStream; + + public class NbtIo { +- private static final OpenOption[] SYNC_OUTPUT_OPTIONS = new OpenOption[]{ +- StandardOpenOption.SYNC, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING +- }; + +- public static CompoundTag readCompressed(Path path, NbtAccounter nbtAccounter) throws IOException { +- CompoundTag var3; +- try (InputStream inputStream = Files.newInputStream(path)) { +- var3 = readCompressed(inputStream, nbtAccounter); ++ private static final OpenOption[] SYNC_OUTPUT_OPTIONS = new OpenOption[]{StandardOpenOption.SYNC, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING}; ++ ++ public NbtIo() {} ++ ++ public static CompoundTag readCompressed(Path path, NbtAccounter nbtreadlimiter) throws IOException { ++ InputStream inputstream = Files.newInputStream(path); ++ ++ CompoundTag nbttagcompound; ++ ++ try { ++ nbttagcompound = readCompressed(inputstream, nbtreadlimiter); ++ } catch (Throwable throwable) { ++ if (inputstream != null) { ++ try { ++ inputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ } ++ ++ throw throwable; + } + +- return var3; ++ if (inputstream != null) { ++ inputstream.close(); ++ } ++ ++ return nbttagcompound; + } + + private static DataInputStream createDecompressorStream(InputStream zippedStream) throws IOException { + return new DataInputStream(new FastBufferedInputStream(new GZIPInputStream(zippedStream))); + } + +- private static DataOutputStream createCompressorStream(OutputStream outputStream) throws IOException { +- return new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(outputStream))); ++ private static DataOutputStream createCompressorStream(OutputStream outputstream) throws IOException { ++ return new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(outputstream))); + } + +- public static CompoundTag readCompressed(InputStream inputStream, NbtAccounter nbtAccounter) throws IOException { +- CompoundTag var3; +- try (DataInputStream dataInputStream = createDecompressorStream(inputStream)) { +- var3 = read(dataInputStream, nbtAccounter); ++ public static CompoundTag readCompressed(InputStream inputstream, NbtAccounter nbtreadlimiter) throws IOException { ++ DataInputStream datainputstream = createDecompressorStream(inputstream); ++ ++ CompoundTag nbttagcompound; ++ ++ try { ++ nbttagcompound = read(datainputstream, nbtreadlimiter); ++ } catch (Throwable throwable) { ++ if (datainputstream != null) { ++ try { ++ datainputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ } ++ ++ throw throwable; + } + +- return var3; ++ if (datainputstream != null) { ++ datainputstream.close(); ++ } ++ ++ return nbttagcompound; + } + +- public static void parseCompressed(Path path, StreamTagVisitor streamTagVisitor, NbtAccounter nbtAccounter) throws IOException { +- try (InputStream inputStream = Files.newInputStream(path)) { +- parseCompressed(inputStream, streamTagVisitor, nbtAccounter); ++ public static void parseCompressed(Path path, StreamTagVisitor streamtagvisitor, NbtAccounter nbtreadlimiter) throws IOException { ++ InputStream inputstream = Files.newInputStream(path); ++ ++ try { ++ parseCompressed(inputstream, streamtagvisitor, nbtreadlimiter); ++ } catch (Throwable throwable) { ++ if (inputstream != null) { ++ try { ++ inputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ } ++ ++ throw throwable; + } ++ ++ if (inputstream != null) { ++ inputstream.close(); ++ } ++ + } + +- public static void parseCompressed(InputStream inputStream, StreamTagVisitor streamTagVisitor, NbtAccounter nbtAccounter) throws IOException { +- try (DataInputStream dataInputStream = createDecompressorStream(inputStream)) { +- parse(dataInputStream, streamTagVisitor, nbtAccounter); ++ public static void parseCompressed(InputStream inputstream, StreamTagVisitor streamtagvisitor, NbtAccounter nbtreadlimiter) throws IOException { ++ DataInputStream datainputstream = createDecompressorStream(inputstream); ++ ++ try { ++ parse(datainputstream, streamtagvisitor, nbtreadlimiter); ++ } catch (Throwable throwable) { ++ if (datainputstream != null) { ++ try { ++ datainputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ } ++ ++ throw throwable; + } ++ ++ if (datainputstream != null) { ++ datainputstream.close(); ++ } ++ + } + +- public static void writeCompressed(CompoundTag compoundTag, Path path) throws IOException { +- try ( +- OutputStream outputStream = Files.newOutputStream(path, SYNC_OUTPUT_OPTIONS); +- OutputStream outputStream1 = new BufferedOutputStream(outputStream); +- ) { +- writeCompressed(compoundTag, outputStream1); ++ public static void writeCompressed(CompoundTag nbttagcompound, Path path) throws IOException { ++ OutputStream outputstream = Files.newOutputStream(path, NbtIo.SYNC_OUTPUT_OPTIONS); ++ ++ try { ++ BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(outputstream); ++ ++ try { ++ writeCompressed(nbttagcompound, (OutputStream) bufferedoutputstream); ++ } catch (Throwable throwable) { ++ try { ++ bufferedoutputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ ++ throw throwable; ++ } ++ ++ bufferedoutputstream.close(); ++ } catch (Throwable throwable2) { ++ if (outputstream != null) { ++ try { ++ outputstream.close(); ++ } catch (Throwable throwable3) { ++ throwable2.addSuppressed(throwable3); ++ } ++ } ++ ++ throw throwable2; + } ++ ++ if (outputstream != null) { ++ outputstream.close(); ++ } ++ + } + + public static void writeCompressed(CompoundTag compoundTag, OutputStream outputStream) throws IOException { +- try (DataOutputStream dataOutputStream = createCompressorStream(outputStream)) { +- write(compoundTag, dataOutputStream); ++ DataOutputStream dataoutputstream = createCompressorStream(outputStream); ++ ++ try { ++ write(compoundTag, (DataOutput) dataoutputstream); ++ } catch (Throwable throwable) { ++ if (dataoutputstream != null) { ++ try { ++ dataoutputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ } ++ ++ throw throwable; + } ++ ++ if (dataoutputstream != null) { ++ dataoutputstream.close(); ++ } ++ + } + +- public static void write(CompoundTag compoundTag, Path path) throws IOException { +- try ( +- OutputStream outputStream = Files.newOutputStream(path, SYNC_OUTPUT_OPTIONS); +- OutputStream outputStream1 = new BufferedOutputStream(outputStream); +- DataOutputStream dataOutputStream = new DataOutputStream(outputStream1); +- ) { +- write(compoundTag, dataOutputStream); ++ public static void write(CompoundTag nbttagcompound, Path path) throws IOException { ++ OutputStream outputstream = Files.newOutputStream(path, NbtIo.SYNC_OUTPUT_OPTIONS); ++ ++ try { ++ BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(outputstream); ++ ++ try { ++ DataOutputStream dataoutputstream = new DataOutputStream(bufferedoutputstream); ++ ++ try { ++ write(nbttagcompound, (DataOutput) dataoutputstream); ++ } catch (Throwable throwable) { ++ try { ++ dataoutputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ ++ throw throwable; ++ } ++ ++ dataoutputstream.close(); ++ } catch (Throwable throwable2) { ++ try { ++ bufferedoutputstream.close(); ++ } catch (Throwable throwable3) { ++ throwable2.addSuppressed(throwable3); ++ } ++ ++ throw throwable2; ++ } ++ ++ bufferedoutputstream.close(); ++ } catch (Throwable throwable4) { ++ if (outputstream != null) { ++ try { ++ outputstream.close(); ++ } catch (Throwable throwable5) { ++ throwable4.addSuppressed(throwable5); ++ } ++ } ++ ++ throw throwable4; + } ++ ++ if (outputstream != null) { ++ outputstream.close(); ++ } ++ + } + + @Nullable + public static CompoundTag read(Path path) throws IOException { +- if (!Files.exists(path)) { ++ if (!Files.exists(path, new LinkOption[0])) { + return null; + } else { +- CompoundTag var3; +- try ( +- InputStream inputStream = Files.newInputStream(path); +- DataInputStream dataInputStream = new DataInputStream(inputStream); +- ) { +- var3 = read(dataInputStream, NbtAccounter.unlimitedHeap()); ++ InputStream inputstream = Files.newInputStream(path); ++ ++ CompoundTag nbttagcompound; ++ ++ try { ++ DataInputStream datainputstream = new DataInputStream(inputstream); ++ ++ try { ++ nbttagcompound = read(datainputstream, NbtAccounter.unlimitedHeap()); ++ } catch (Throwable throwable) { ++ try { ++ datainputstream.close(); ++ } catch (Throwable throwable1) { ++ throwable.addSuppressed(throwable1); ++ } ++ ++ throw throwable; ++ } ++ ++ datainputstream.close(); ++ } catch (Throwable throwable2) { ++ if (inputstream != null) { ++ try { ++ inputstream.close(); ++ } catch (Throwable throwable3) { ++ throwable2.addSuppressed(throwable3); ++ } ++ } ++ ++ throw throwable2; + } + +- return var3; ++ if (inputstream != null) { ++ inputstream.close(); ++ } ++ ++ return nbttagcompound; + } + } + +@@ -112,9 +297,10 @@ + } + + public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException { +- Tag unnamedTag = readUnnamedTag(input, accounter); +- if (unnamedTag instanceof CompoundTag) { +- return (CompoundTag)unnamedTag; ++ Tag nbtbase = readUnnamedTag(input, accounter); ++ ++ if (nbtbase instanceof CompoundTag) { ++ return (CompoundTag) nbtbase; + } else { + throw new IOException("Root tag must be a named compound tag"); + } +@@ -124,37 +310,41 @@ + writeUnnamedTagWithFallback(compoundTag, output); + } + +- public static void parse(DataInput dataInput, StreamTagVisitor streamTagVisitor, NbtAccounter nbtAccounter) throws IOException { +- TagType<?> type = TagTypes.getType(dataInput.readByte()); +- if (type == EndTag.TYPE) { +- if (streamTagVisitor.visitRootEntry(EndTag.TYPE) == StreamTagVisitor.ValueResult.CONTINUE) { +- streamTagVisitor.visitEnd(); ++ public static void parse(DataInput datainput, StreamTagVisitor streamtagvisitor, NbtAccounter nbtreadlimiter) throws IOException { ++ TagType<?> nbttagtype = TagTypes.getType(datainput.readByte()); ++ ++ if (nbttagtype == EndTag.TYPE) { ++ if (streamtagvisitor.visitRootEntry(EndTag.TYPE) == StreamTagVisitor.b.CONTINUE) { ++ streamtagvisitor.visitEnd(); + } ++ + } else { +- switch (streamTagVisitor.visitRootEntry(type)) { ++ switch (streamtagvisitor.visitRootEntry(nbttagtype)) { + case HALT: + default: + break; + case BREAK: +- StringTag.skipString(dataInput); +- type.skip(dataInput, nbtAccounter); ++ StringTag.skipString(datainput); ++ nbttagtype.skip(datainput, nbtreadlimiter); + break; + case CONTINUE: +- StringTag.skipString(dataInput); +- type.parse(dataInput, streamTagVisitor, nbtAccounter); ++ StringTag.skipString(datainput); ++ nbttagtype.parse(datainput, streamtagvisitor, nbtreadlimiter); + } ++ + } + } + +- public static Tag readAnyTag(DataInput dataInput, NbtAccounter nbtAccounter) throws IOException { +- byte _byte = dataInput.readByte(); +- return (Tag)(_byte == 0 ? EndTag.INSTANCE : readTagSafe(dataInput, nbtAccounter, _byte)); ++ public static Tag readAnyTag(DataInput datainput, NbtAccounter nbtreadlimiter) throws IOException { ++ byte b0 = datainput.readByte(); ++ ++ return (Tag) (b0 == 0 ? EndTag.INSTANCE : readTagSafe(datainput, nbtreadlimiter, b0)); + } + +- public static void writeAnyTag(Tag tag, DataOutput dataOutput) throws IOException { +- dataOutput.writeByte(tag.getId()); +- if (tag.getId() != 0) { +- tag.write(dataOutput); ++ public static void writeAnyTag(Tag nbtbase, DataOutput dataoutput) throws IOException { ++ dataoutput.writeByte(nbtbase.getId()); ++ if (nbtbase.getId() != 0) { ++ nbtbase.write(dataoutput); + } + } + +@@ -166,44 +356,48 @@ + } + } + +- public static void writeUnnamedTagWithFallback(Tag tag, DataOutput dataOutput) throws IOException { +- writeUnnamedTag(tag, new NbtIo.StringFallbackDataOutput(dataOutput)); ++ public static void writeUnnamedTagWithFallback(Tag nbtbase, DataOutput dataoutput) throws IOException { ++ writeUnnamedTag(nbtbase, new NbtIo.a(dataoutput)); + } + +- private static Tag readUnnamedTag(DataInput dataInput, NbtAccounter nbtAccounter) throws IOException { +- byte _byte = dataInput.readByte(); +- if (_byte == 0) { ++ private static Tag readUnnamedTag(DataInput datainput, NbtAccounter nbtreadlimiter) throws IOException { ++ byte b0 = datainput.readByte(); ++ ++ if (b0 == 0) { + return EndTag.INSTANCE; + } else { +- StringTag.skipString(dataInput); +- return readTagSafe(dataInput, nbtAccounter, _byte); ++ StringTag.skipString(datainput); ++ return readTagSafe(datainput, nbtreadlimiter, b0); + } + } + +- private static Tag readTagSafe(DataInput dataInput, NbtAccounter nbtAccounter, byte b) { ++ private static Tag readTagSafe(DataInput datainput, NbtAccounter nbtreadlimiter, byte b0) { + try { +- return TagTypes.getType(b).load(dataInput, nbtAccounter); +- } catch (IOException var6) { +- CrashReport crashReport = CrashReport.forThrowable(var6, "Loading NBT data"); +- CrashReportCategory crashReportCategory = crashReport.addCategory("NBT Tag"); +- crashReportCategory.setDetail("Tag type", b); +- throw new ReportedNbtException(crashReport); ++ return TagTypes.getType(b0).load(datainput, nbtreadlimiter); ++ } catch (IOException ioexception) { ++ CrashReport crashreport = CrashReport.forThrowable(ioexception, "Loading NBT data"); ++ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("NBT Tag"); ++ ++ crashreportsystemdetails.setDetail("Tag type", (Object) b0); ++ throw new ReportedNbtException(crashreport); + } + } + +- public static class StringFallbackDataOutput extends DelegateDataOutput { +- public StringFallbackDataOutput(DataOutput dataOutput) { +- super(dataOutput); ++ public static class a extends DelegateDataOutput { ++ ++ public a(DataOutput dataoutput) { ++ super(dataoutput); + } + + @Override +- public void writeUTF(String string) throws IOException { ++ public void writeUTF(String s) throws IOException { + try { +- super.writeUTF(string); +- } catch (UTFDataFormatException var3) { +- Util.logAndPauseIfInIde("Failed to write NBT String", var3); ++ super.writeUTF(s); ++ } catch (UTFDataFormatException utfdataformatexception) { ++ Util.logAndPauseIfInIde("Failed to write NBT String", utfdataformatexception); + super.writeUTF(""); + } ++ + } + } + } |