Skip to content

Commit

Permalink
UNSTABLE: added block.break! which breaks a block
Browse files Browse the repository at this point in the history
This almost feels like breaking the block with a pickaxe or
something. Their material will be randomly dropped on the Ground which
makes this a quite nice feature. However, in many cases (not yet
reproduced) the Client will die due to NullPointerException! So be
warened, this is higly unstable!
  • Loading branch information
Marv Cool committed Nov 29, 2011
1 parent 7958076 commit 9f8521e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/generators/tunnel.rb
Expand Up @@ -36,7 +36,7 @@ def on_enable
block = deep_block.block_at(height_facing,height_dist)
width.times do |width_dist|
# for now the block will only be replaced by air. No mining.
block.block_at(width_facing,width_dist).change_type :air
block.block_at(width_facing,width_dist).break!
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions src/bukkit/block/block.rb
Expand Up @@ -58,6 +58,13 @@ def rotate(face,direction)
face_for_symbol(ROTATIONS[symbol_for_face(face)][direction])
end

def break!
mat = self.get_type
itemstack = org::bukkit::inventory::ItemStack.new(mat,1)
location.world.drop_item_naturally(location,itemstack)
self.change_type :air
end

def face_for_symbol(value)
FACE_VALUES[value]
end
Expand Down

0 comments on commit 9f8521e

Please sign in to comment.