Skip to content

Commit

Permalink
furnaces: Changed cube.Face to cube.Direction (#840)
Browse files Browse the repository at this point in the history
- Fixes #833

This happend because a furnace(or other blocks) cannot face for  an example down or up but cube.Face default is down so an error occured so we are using cube.Direction now for the Facing.
  • Loading branch information
Erkam246 authored Apr 1, 2024
1 parent 1ce4134 commit 55fee47
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions server/block/blast_furnace.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ type BlastFurnace struct {
*smelter

// Facing is the direction the blast furnace is facing.
Facing cube.Face
Facing cube.Direction
// Lit is true if the blast furnace is lit.
Lit bool
}

// NewBlastFurnace creates a new initialised blast furnace. The smelter is properly initialised.
func NewBlastFurnace(face cube.Face) BlastFurnace {
func NewBlastFurnace(face cube.Direction) BlastFurnace {
return BlastFurnace{
Facing: face,
smelter: newSmelter(),
Expand Down Expand Up @@ -66,7 +66,7 @@ func (b BlastFurnace) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *
return false
}

place(w, pos, NewBlastFurnace(user.Rotation().Direction().Face().Opposite()), user, ctx)
place(w, pos, NewBlastFurnace(user.Rotation().Direction().Opposite()), user, ctx)
return placed(ctx)
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func (b BlastFurnace) DecodeNBT(data map[string]interface{}) interface{} {

// allBlastFurnaces ...
func allBlastFurnaces() (furnaces []world.Block) {
for _, face := range cube.HorizontalFaces() {
for _, face := range cube.Directions() {
furnaces = append(furnaces, BlastFurnace{Facing: face})
furnaces = append(furnaces, BlastFurnace{Facing: face, Lit: true})
}
Expand Down
8 changes: 4 additions & 4 deletions server/block/furnace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ type Furnace struct {
*smelter

// Facing is the direction the furnace is facing.
Facing cube.Face
Facing cube.Direction
// Lit is true if the furnace is lit.
Lit bool
}

// NewFurnace creates a new initialised furnace. The smelter is properly initialised.
func NewFurnace(face cube.Face) Furnace {
func NewFurnace(face cube.Direction) Furnace {
return Furnace{
Facing: face,
smelter: newSmelter(),
Expand Down Expand Up @@ -65,7 +65,7 @@ func (f Furnace) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world
return false
}

place(w, pos, NewFurnace(user.Rotation().Direction().Face().Opposite()), user, ctx)
place(w, pos, NewFurnace(user.Rotation().Direction().Opposite()), user, ctx)
return placed(ctx)
}

Expand Down Expand Up @@ -121,7 +121,7 @@ func (f Furnace) DecodeNBT(data map[string]interface{}) interface{} {

// allFurnaces ...
func allFurnaces() (furnaces []world.Block) {
for _, face := range cube.HorizontalFaces() {
for _, face := range cube.Directions() {
furnaces = append(furnaces, Furnace{Facing: face})
furnaces = append(furnaces, Furnace{Facing: face, Lit: true})
}
Expand Down
6 changes: 3 additions & 3 deletions server/block/lectern.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Lectern struct {
sourceWaterDisplacer

// Facing represents the direction the Lectern is facing.
Facing cube.Face
Facing cube.Direction
// Book is the book currently held by the Lectern.
Book item.Stack
// Page is the page the Lectern is currently on in the book.
Expand Down Expand Up @@ -57,7 +57,7 @@ func (l Lectern) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world
if !used {
return false
}
l.Facing = user.Rotation().Direction().Face().Opposite()
l.Facing = user.Rotation().Direction().Opposite()
place(w, pos, l, user, ctx)
return placed(ctx)
}
Expand Down Expand Up @@ -159,7 +159,7 @@ func (l Lectern) EncodeBlock() (string, map[string]any) {

// allLecterns ...
func allLecterns() (lecterns []world.Block) {
for _, f := range cube.HorizontalFaces() {
for _, f := range cube.Directions() {
lecterns = append(lecterns, Lectern{Facing: f})
}
return
Expand Down
8 changes: 4 additions & 4 deletions server/block/smoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ type Smoker struct {
*smelter

// Facing is the direction the smoker is facing.
Facing cube.Face
Facing cube.Direction
// Lit is true if the smoker is lit.
Lit bool
}

// NewSmoker creates a new initialised smoker. The smelter is properly initialised.
func NewSmoker(face cube.Face) Smoker {
func NewSmoker(face cube.Direction) Smoker {
return Smoker{
Facing: face,
smelter: newSmelter(),
Expand Down Expand Up @@ -66,7 +66,7 @@ func (s Smoker) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.
return false
}

place(w, pos, NewSmoker(user.Rotation().Direction().Face().Opposite()), user, ctx)
place(w, pos, NewSmoker(user.Rotation().Direction().Opposite()), user, ctx)
return placed(ctx)
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func (s Smoker) DecodeNBT(data map[string]interface{}) interface{} {

// allSmokers ...
func allSmokers() (smokers []world.Block) {
for _, face := range cube.HorizontalFaces() {
for _, face := range cube.Directions() {
smokers = append(smokers, Smoker{Facing: face})
smokers = append(smokers, Smoker{Facing: face, Lit: true})
}
Expand Down

0 comments on commit 55fee47

Please sign in to comment.