Skip to content

Commit

Permalink
allow repeaters to be placed on pistons
Browse files Browse the repository at this point in the history
  • Loading branch information
xNatsuri committed Jan 9, 2025
1 parent 5e0d84f commit 2596838
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions server/block/redstone_repeater.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package block

import (
"fmt"
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/block/model"
"github.com/df-mc/dragonfly/server/item"
Expand Down Expand Up @@ -65,9 +64,13 @@ func (r RedstoneRepeater) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3,
if !used {
return false
}
if d, ok := tx.Block(pos.Side(cube.FaceDown)).(LightDiffuser); ok && d.LightDiffusionLevel() == 0 {
return false
b := tx.Block(pos.Side(cube.FaceDown))
if d, ok := b.(LightDiffuser); ok && d.LightDiffusionLevel() == 0 {
if _, isPiston := b.(Piston); !isPiston {
return false
}
}

r.Facing = user.Rotation().Direction().Opposite()

place(tx, pos, r, user, ctx)
Expand All @@ -80,9 +83,12 @@ func (r RedstoneRepeater) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3,

// NeighbourUpdateTick ...
func (r RedstoneRepeater) NeighbourUpdateTick(pos, _ cube.Pos, tx *world.Tx) {
if d, ok := tx.Block(pos.Side(cube.FaceDown)).(LightDiffuser); ok && d.LightDiffusionLevel() == 0 {
tx.SetBlock(pos, nil, nil)
dropItem(tx, item.NewStack(r, 1), pos.Vec3Centre())
b := tx.Block(pos.Side(cube.FaceDown))
if d, ok := b.(LightDiffuser); ok && d.LightDiffusionLevel() == 0 {
if _, piston := b.(Piston); !piston {
tx.SetBlock(pos, nil, nil)
dropItem(tx, item.NewStack(r, 1), pos.Vec3Centre())
}
}
}

Expand Down Expand Up @@ -133,7 +139,6 @@ func (r RedstoneRepeater) Locked(pos cube.Pos, tx *world.Tx) bool {
func (r RedstoneRepeater) locking(pos cube.Pos, direction cube.Direction, tx *world.Tx) bool {
block := tx.Block(pos)

fmt.Println(block.EncodeBlock())
if repeater, ok := block.(RedstoneRepeater); ok {
return repeater.Powered && repeater.Facing == direction
}
Expand Down

0 comments on commit 2596838

Please sign in to comment.