Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'minecraft-pi-ruby'
N = 41
xs = []
(N + 2).times do |y|
xs[y] = ' ' * (N + 2)
end
(N + 2).times do |y|
(N + 2).times do |x|
if (y == 0 || y == N + 1) || (x == 0 || x == N + 1)
xs[y][x] = '#'
elsif (y % 2 == 0 && x % 2 == 0)
xs[y][x] = '#'
case Random.rand(4)
when 0
xs[y - 1][x] = '#'
when 1
xs[y][x + 1] = '#'
when 2
xs[y + 1][x] = '#'
when 3
xs[y][x - 1] = '#'
end
end
end
end
xs.each do |line|
puts line
end
mc = Minecraft.new
mc.set_player_position(0, 100, 0)
mc.set_blocks(-500, -1, -500, 500, -1, 500, Block::STONE)
mc.set_blocks(-500, 0, -500, 500, 64, 500, Block::AIR)
W = 10
H = 20
base_x = - (N / 2 * 5)
base_y = - (N / 2 * 5)
xs.each_with_index do |line, idx_x|
line.each_char.with_index do |elm, idx_y|
if elm == '#'
mc.set_blocks(base_x + W * idx_x, 0, base_y + W * idx_y, base_x + W * (idx_x + 1), H, base_y + W * (idx_y + 1), Block::DIAMOND_BLOCK)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment