Class: RubyCraft::Block
- Inherits:
-
Object
- Object
- RubyCraft::Block
- Defined in:
- lib/rubycraft/block.rb
Overview
A minecraft block. Its position is given by a coord[x, z, y]
Instance Attribute Summary collapse
-
#block_type ⇒ Object
Returns the value of attribute block_type.
-
#data ⇒ Object
Returns the value of attribute data.
-
#pos ⇒ Object
Returns the value of attribute pos.
Class Method Summary collapse
Instance Method Summary collapse
- #blockColor ⇒ Object
- #color ⇒ Object
- #color=(color) ⇒ Object
- #id ⇒ Object
-
#id=(id) ⇒ Object
sets block type by id.
-
#initialize(blockType, data = 0) ⇒ Block
constructor
A new instance of Block.
- #is(name) ⇒ Object
- #name ⇒ Object
-
#name=(newName) ⇒ Object
sets block type by name.
- #transparent ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
- #z ⇒ Object
Constructor Details
#initialize(blockType, data = 0) ⇒ Block
Returns a new instance of Block.
8 9 10 11 |
# File 'lib/rubycraft/block.rb', line 8 def initialize(blockType, data = 0) @blockType = blockType @data = 0 end |
Instance Attribute Details
#block_type ⇒ Object
Returns the value of attribute block_type.
7 8 9 |
# File 'lib/rubycraft/block.rb', line 7 def block_type @block_type end |
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/rubycraft/block.rb', line 7 def data @data end |
#pos ⇒ Object
Returns the value of attribute pos.
7 8 9 |
# File 'lib/rubycraft/block.rb', line 7 def pos @pos end |
Class Method Details
.[](key) ⇒ Object
21 22 23 |
# File 'lib/rubycraft/block.rb', line 21 def self.[](key) new BlockType[key] end |
.get(key) ⇒ Object
13 14 15 |
# File 'lib/rubycraft/block.rb', line 13 def self.get(key) new BlockType.get key end |
.of(key) ⇒ Object
17 18 19 |
# File 'lib/rubycraft/block.rb', line 17 def self.of(key) self[key] end |
Instance Method Details
#blockColor ⇒ Object
34 35 36 |
# File 'lib/rubycraft/block.rb', line 34 def blockColor BlockColor.typeColor[@data] end |
#color ⇒ Object
30 31 32 |
# File 'lib/rubycraft/block.rb', line 30 def color BlockColor.typeColor[@data].name end |
#color=(color) ⇒ Object
26 27 28 |
# File 'lib/rubycraft/block.rb', line 26 def color=(color) @data = BlockColor::InvertedColor[color] end |
#id ⇒ Object
46 47 48 |
# File 'lib/rubycraft/block.rb', line 46 def id @blockType.id end |
#id=(id) ⇒ Object
sets block type by id
61 62 63 64 |
# File 'lib/rubycraft/block.rb', line 61 def id=(id) return if id == id @blockType = BlockType.get id end |
#is(name) ⇒ Object
38 39 40 |
# File 'lib/rubycraft/block.rb', line 38 def is(name) self.name == name.to_s end |
#name ⇒ Object
42 43 44 |
# File 'lib/rubycraft/block.rb', line 42 def name @blockType.name end |
#name=(newName) ⇒ Object
sets block type by name
55 56 57 58 |
# File 'lib/rubycraft/block.rb', line 55 def name=(newName) return if name == newName.to_s @blockType = BlockType[newName] end |
#transparent ⇒ Object
50 51 52 |
# File 'lib/rubycraft/block.rb', line 50 def transparent @blockType.transparent end |
#x ⇒ Object
74 75 76 |
# File 'lib/rubycraft/block.rb', line 74 def x pos[0] end |
#y ⇒ Object
66 67 68 |
# File 'lib/rubycraft/block.rb', line 66 def y pos[2] end |
#z ⇒ Object
70 71 72 |
# File 'lib/rubycraft/block.rb', line 70 def z pos[1] end |