-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: type=="foo" and type=="bar" #3
Comments
Minecraft inner workings Minecraft mod tools: |
@professor something like this? class Player
def mine(tool, block)
if Block.INDESTRUCTIBLE.include?(block.type)
return
end
if tool.type == :pick && !Block.MINEABLE_BY_PICK.include?(block.type)
# destroy the block without dropping anything
block.destroy!
return
end
if tool.type == :shovel && !Block.MINEABLE_BY_SHOVEL.include?(block.type)
# destroy the block without dropping anything
block.destroy!
return
end
if tool.strength < Tool.STONE && block.hardness >= Block.IRON ||
tool.strength < Tool.DIAMOND && block.hardness >= Block.OBSIDIAN
# destroy block without dropping anything
block.destroy!
return
end
if block.type == :redstone
# redstone drops multiple items
block.drop_all([:redstone] * rand(4..6))
block.destroy!
return
end
if block.type == :lapis
# lapis drops multiple items
block.drop_all([:lapis] * rand(2..4))
block.destroy!
return
end
if block.type == :cracked_stone
block.destroy!
# cracked stone doesn't drop anything
return
end
# default case: drop one item
block.drop(block.type)
block.destroy!
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's an object or strategies waiting in every code base?
The text was updated successfully, but these errors were encountered: