-
-
Save 2called-chaos/d7471189fc0f5abac3e14bd9b8acf4de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_map_id world = nil | |
return false unless File.exist?(nbt_path("data/idcounts.dat", world)) | |
file = File.open(nbt_path("data/idcounts.dat", world)) | |
cstrio = StringIO.new("rw") | |
gz = Zlib::GzipWriter.new(cstrio) | |
gz.write file.read | |
gz.close | |
cstrio.reopen("r") | |
cstrio.rewind | |
NBTFile.load(cstrio) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[28] pry(#<Mcl::HMclImageMaps>)> cstrio = StringIO.new("rw") | |
=> #<StringIO:0x007f92164baed8> | |
[29] pry(#<Mcl::HMclImageMaps>)> gz = Zlib::GzipWriter.new(cstrio) | |
=> #<Zlib::GzipWriter:0x007f9216499170> | |
[30] pry(#<Mcl::HMclImageMaps>)> file = File.open(nbt_path("data/idcounts.dat", world)) | |
=> #<File:/Volumes/code/_private/mcl/_server/world/data/idcounts.dat> | |
[31] pry(#<Mcl::HMclImageMaps>)> gz.write file.read | |
=> 12 | |
[32] pry(#<Mcl::HMclImageMaps>)> file.rewind | |
=> 0 | |
[33] pry(#<Mcl::HMclImageMaps>)> file.read | |
=> "\n\u0000\u0000\u0002\u0000\u0003map\u0000\u0000\u0000" | |
[34] pry(#<Mcl::HMclImageMaps>)> cstrio | |
=> #<StringIO:0x007f92164baed8> | |
[35] pry(#<Mcl::HMclImageMaps>)> cstrio.length | |
=> 10 | |
[36] pry(#<Mcl::HMclImageMaps>)> gz.close | |
=> #<StringIO:0x007f92164baed8> | |
[37] pry(#<Mcl::HMclImageMaps>)> cstrio.length | |
=> 32 | |
[38] pry(#<Mcl::HMclImageMaps>)> cstrio.rewind | |
=> 0 | |
[39] pry(#<Mcl::HMclImageMaps>)> cstrio.read | |
IOError: not opened for reading | |
from (pry):45:in `read' | |
[40] pry(#<Mcl::HMclImageMaps>)> cstrio.reopen | |
=> #<StringIO:0x007f92164baed8> | |
[41] pry(#<Mcl::HMclImageMaps>)> cstrio.read | |
=> "" | |
[42] pry(#<Mcl::HMclImageMaps>)> cstrio.length | |
=> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment