Class: RubyCraft::LazyChunkDelegate
Instance Method Summary
collapse
Methods included from ZlibHelper
#compress, #decompress
#arrayToIO, #bytesToInt, #concat, #intBytes, #pad, #stringToByteArray, #stringToIo, #toByteString
Constructor Details
Returns a new instance of LazyChunkDelegate.
8
9
10
11
|
# File 'lib/rubycraft/region.rb', line 8
def initialize(bytes)
@bytes = bytes
@chunk = nil
end
|
Instance Method Details
#[](z, x, y) ⇒ Object
24
25
26
|
# File 'lib/rubycraft/region.rb', line 24
def [](z, x, y)
_getchunk[z, x, y]
end
|
#[]=(z, x, y, value) ⇒ Object
28
29
30
|
# File 'lib/rubycraft/region.rb', line 28
def []=(z, x, y, value)
_getchunk[z, x, y] = value
end
|
#_unload ⇒ Object
unloacs the loaded chunk. Needed for memory optmization
44
45
46
47
48
|
# File 'lib/rubycraft/region.rb', line 44
def _unload
return if @chunk.nil?
@bytes = @chunk.toNbt
@chunk = nil
end
|
#block_map(&block) ⇒ Object
17
18
19
|
# File 'lib/rubycraft/region.rb', line 17
def block_map(&block)
_getchunk.block_map &block
end
|
#block_type_map(&block) ⇒ Object
20
21
22
|
# File 'lib/rubycraft/region.rb', line 20
def block_type_map(&block)
_getchunk.block_type_map &block
end
|
#each(&block) ⇒ Object
13
14
15
|
# File 'lib/rubycraft/region.rb', line 13
def each(&block)
_getchunk.each &block
end
|
#export ⇒ Object
32
33
34
|
# File 'lib/rubycraft/region.rb', line 32
def export
_getchunk.export
end
|
#toNbt ⇒ Object
37
38
39
40
|
# File 'lib/rubycraft/region.rb', line 37
def toNbt
return @bytes if @chunk.nil?
@chunk.toNbt
end
|