From 674dff6a1ae9184d04d3a8f55e7df4b5b2d7d1ae Mon Sep 17 00:00:00 2001 From: Nicholas Winterhalter <78866820+Gewinum@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:41:10 +0400 Subject: [PATCH] block/ladder.go: Change Direction to Face to allow states 0 and 1 (#907) --- server/block/ladder.go | 15 ++++++++------- server/block/model/ladder.go | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/block/ladder.go b/server/block/ladder.go index 0e62a68ca..48e26076b 100644 --- a/server/block/ladder.go +++ b/server/block/ladder.go @@ -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()) @@ -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) @@ -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 ... @@ -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 } diff --git a/server/block/model/ladder.go b/server/block/model/ladder.go index 93274019c..cd18b8938 100644 --- a/server/block/model/ladder.go +++ b/server/block/model/ladder.go @@ -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.