Class: McBlocky::DSL::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/mcblocky/dsl/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dataObject (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_kindObject (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

#nbtObject (readonly)

Returns the value of attribute nbt.



3
4
5
# File 'lib/mcblocky/dsl/container.rb', line 3

def nbt
  @nbt
end

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/mcblocky/dsl/container.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/mcblocky/dsl/container.rb', line 3

def y
  @y
end

#zObject (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