Skip to content

Commit

Permalink
fixed a bug where crafting tools wouldn't remove materials from inven…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
RepublicOfMars committed Apr 29, 2021
1 parent e44338f commit 6afe250
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
11 changes: 9 additions & 2 deletions Sources/ScenesShell/BackgroundLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class BackgroundLayer : Layer, KeyDownHandler, KeyUpHandler, MouseMoveHandler, M
}
}

camera.move(x:Double(spawnLocation.x), y:Double(64/*spawnY*/), z:Double(spawnLocation.z))
camera.move(x:Double(spawnLocation.x), y:Double(spawnY), z:Double(spawnLocation.z))
}

override func preSetup(canvasSize:Size, canvas:Canvas) {
Expand Down Expand Up @@ -483,7 +483,14 @@ class BackgroundLayer : Layer, KeyDownHandler, KeyUpHandler, MouseMoveHandler, M
canvas.render(Text(location:Point(x:20, y:70), text:"Yaw: \(camera.yaw)", fillMode:.fill))
canvas.render(Text(location:Point(x:20, y:80), text:"Framerate: 8", fillMode:.fill))
canvas.render(Text(location:Point(x:20, y:90), text:"Computers Connected: \(BackgroundLayer.computerCount)", fillMode:.fill))
canvas.render(Text(location:Point(x:20, y:100), text:"Frame: \(BackgroundLayer.frame), Sun Angle: \(Int(sunAngle)%360)", fillMode:.fill))
canvas.render(Text(location:Point(x:20, y:100), text:"Render Distance: \(world.renderDistance)", fillMode:.fill))
let seconds = BackgroundLayer.frame/8
let minutes = seconds/60
var secondsString = "\(seconds%60)"
if secondsString.count < 2 {
secondsString = "0\(secondsString)"
}
canvas.render(Text(location:Point(x:20, y:110), text:"Frame: \(BackgroundLayer.frame), Run Time: \(minutes):\(secondsString)", fillMode:.fill))
canvas.render(Text(location:Point(x:20, y:canvas.canvasSize!.height-20), text:">\(command)", fillMode:.fill))

//show selected block
Expand Down
2 changes: 1 addition & 1 deletion Sources/ScenesShell/Block.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Block {
hardness = 0
}
if type == "grass" || type == "stone" || type == "dirt" {
let variation = Int(32*DoubleNoise(x:Double(location.x)+0.1, y:Double(location.y)+0.1, z:Double(location.z)+0.1))
let variation = Int(16*DoubleNoise(x:Double(location.x)+0.1, y:Double(location.y)+0.1, z:Double(location.z)+0.1))
color = Color(red:UInt8(Int(color.red)+variation),
green:UInt8(Int(color.green)+variation),
blue:UInt8(Int(color.blue)+variation))
Expand Down
3 changes: 3 additions & 0 deletions Sources/ScenesShell/Crafting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class CraftingRecipe {
if !success {
return false
} else {
for item in itemsIn {
let _ = inventory.removeItem(item.name, count:item.count)
}
let toolArguments = itemOut.name.split(separator:"_")
let toolMaterial = toolArguments[0]
let toolType = toolArguments[1]
Expand Down
12 changes: 6 additions & 6 deletions Sources/ScenesShell/Path3d.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class Path3d {
canvas.render(StrokeStyle(color:Color(red:64, green:64, blue:64)))
} else {
var colorOutline = (red:color.red, green:color.green, blue:color.blue)
if color.red > 4 {
colorOutline.red -= 4
if color.red > 0 {
colorOutline.red -= 1
}
if color.green > 4 {
colorOutline.green -= 4
if color.green > 0 {
colorOutline.green -= 1
}
if color.blue > 4 {
colorOutline.blue -= 4
if color.blue > 0 {
colorOutline.blue -= 1
}
canvas.render(StrokeStyle(color:Color(red:colorOutline.red, green:colorOutline.green, blue:colorOutline.blue)))
}
Expand Down

0 comments on commit 6afe250

Please sign in to comment.