Skip to content
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

block/ladder.go: Change Direction to Face to allow states 0 and 1 #907

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions server/block/ladder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ type Ladder struct {
transparent
sourceWaterDisplacer

// Facing is the side of the block the ladder is currently attached to.
Facing cube.Direction
// Facing is the side of the block the ladder is currently attached to. cube.FaceDown and cube.FaceUp
// do not do anything in game but they are still valid states.
Facing cube.Face
}

// NeighbourUpdateTick ...
func (l Ladder) NeighbourUpdateTick(pos, _ cube.Pos, w *world.World) {
if _, ok := w.Block(pos.Side(l.Facing.Opposite().Face())).(LightDiffuser); ok {
if _, ok := w.Block(pos.Side(l.Facing.Opposite())).(LightDiffuser); ok {
w.SetBlock(pos, nil, nil)
w.AddParticle(pos.Vec3Centre(), particle.BlockBreak{Block: l})
dropItem(w, item.NewStack(l, 1), pos.Vec3Centre())
Expand Down Expand Up @@ -51,7 +52,7 @@ func (l Ladder) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.
return false
}
}
l.Facing = face.Direction()
l.Facing = face

place(w, pos, l, user, ctx)
return placed(ctx)
Expand Down Expand Up @@ -86,7 +87,7 @@ func (l Ladder) EncodeItem() (name string, meta int16) {

// EncodeBlock ...
func (l Ladder) EncodeBlock() (string, map[string]any) {
return "minecraft:ladder", map[string]any{"facing_direction": int32(l.Facing + 2)}
return "minecraft:ladder", map[string]any{"facing_direction": int32(l.Facing)}
}

// Model ...
Expand All @@ -96,8 +97,8 @@ func (l Ladder) Model() world.BlockModel {

// allLadders ...
func allLadders() (b []world.Block) {
for i := cube.Direction(0); i <= 3; i++ {
b = append(b, Ladder{Facing: i})
for _, f := range cube.Faces() {
b = append(b, Ladder{Facing: f})
}
return
}
4 changes: 2 additions & 2 deletions server/block/model/ladder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
// Ladder is the model for a ladder block.
type Ladder struct {
// Facing is the side opposite to the block the Ladder is currently attached to.
Facing cube.Direction
Facing cube.Face
}

// BBox returns one physics.BBox that depends on the facing direction of the Ladder.
func (l Ladder) BBox(cube.Pos, *world.World) []cube.BBox {
return []cube.BBox{full.ExtendTowards(l.Facing.Face(), -0.8125)}
return []cube.BBox{full.ExtendTowards(l.Facing, -0.8125)}
}

// FaceSolid always returns false.
Expand Down
Loading