Class: McBlocky::DSL::CommandBlock

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

Constant Summary

Constants inherited from Commands

McBlocky::DSL::Commands::COMMANDS

Instance Attribute Summary collapse

Attributes inherited from Commands

#commands, #context, #kind

Instance Method Summary collapse

Methods inherited from Commands

#activate, #blockdata, #detect, #disable, #enable, #execute, #gamerule, #replaceitem, #scoreboard, #setblock, #tellraw, #title, #to_nbt

Constructor Details

#initialize(context, x, y, z, facing, kind, nbt = {}) ⇒ CommandBlock

Returns a new instance of CommandBlock.



4
5
6
7
8
9
10
11
12
# File 'lib/mcblocky/dsl/command_block.rb', line 4

def initialize(context, x, y, z, facing, kind, nbt={})
  super(context, :at)
  @x = x
  @y = y
  @z = z
  @block_data = facing
  @block_kind = kind
  @nbt = nbt
end

Instance Attribute Details

#block_dataObject (readonly)

Returns the value of attribute block_data.



3
4
5
# File 'lib/mcblocky/dsl/command_block.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/command_block.rb', line 3

def block_kind
  @block_kind
end

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

#zObject (readonly)

Returns the value of attribute z.



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

def z
  @z
end

Instance Method Details

#command(*args) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/mcblocky/dsl/command_block.rb', line 14

def command(*args)
  raise ArgumentError, "Only one command is allowed per block" unless commands.empty?
  super
end

#nbtObject



19
20
21
# File 'lib/mcblocky/dsl/command_block.rb', line 19

def nbt
  return @nbt.merge({'Command'=>commands[0] || ''})
end