Class: McBlocky::DSL::Container
- Inherits:
-
Object
- Object
- McBlocky::DSL::Container
- Defined in:
- lib/mcblocky/dsl/container.rb
Instance Attribute Summary collapse
-
#block_data ⇒ Object
readonly
Returns the value of attribute block_data.
-
#block_kind ⇒ Object
readonly
Returns the value of attribute block_kind.
-
#nbt ⇒ Object
readonly
Returns the value of attribute nbt.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Instance Method Summary collapse
-
#initialize(x, y, z, kind, data = 0, nbt = {}) ⇒ Container
constructor
A new instance of Container.
- #item(kind, count = 1, damage = 0, tag = {}) ⇒ Object
- #item_in_slot(slot, kind, count = 1, damage = 0, tag = {}) ⇒ Object
Constructor Details
#initialize(x, y, z, kind, data = 0, nbt = {}) ⇒ Container
Returns a new instance of Container.
4 5 6 7 8 9 10 11 12 |
# File 'lib/mcblocky/dsl/container.rb', line 4 def initialize(x, y, z, kind, data=0, nbt={}) @x = x @y = y @z = z @block_kind = kind @block_data = data @nbt = nbt @last_slot = -1 end |
Instance Attribute Details
#block_data ⇒ Object (readonly)
Returns the value of attribute block_data.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def block_data @block_data end |
#block_kind ⇒ Object (readonly)
Returns the value of attribute block_kind.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def block_kind @block_kind end |
#nbt ⇒ Object (readonly)
Returns the value of attribute nbt.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def nbt @nbt end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def y @y end |
#z ⇒ Object (readonly)
Returns the value of attribute z.
3 4 5 |
# File 'lib/mcblocky/dsl/container.rb', line 3 def z @z end |
Instance Method Details
#item(kind, count = 1, damage = 0, tag = {}) ⇒ Object
20 21 22 |
# File 'lib/mcblocky/dsl/container.rb', line 20 def item(kind, count=1, damage=0, tag={}) item_in_slot(@last_slot+1, kind, count, damage, tag) end |
#item_in_slot(slot, kind, count = 1, damage = 0, tag = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/mcblocky/dsl/container.rb', line 14 def item_in_slot(slot, kind, count=1, damage=0, tag={}) nbt['Items'] ||= [] nbt['Items'] << {'Slot'=>slot, 'id'=>kind, 'Count'=>count, 'Damage'=>damage, 'tag'=>tag} @last_slot = slot if slot > @last_slot end |