Skip to content

Implement Bell#1211

Open
AkmalFairuz wants to merge 1 commit intodf-mc:masterfrom
AkmalFairuz:bell
Open

Implement Bell#1211
AkmalFairuz wants to merge 1 commit intodf-mc:masterfrom
AkmalFairuz:bell

Conversation

@AkmalFairuz
Copy link
Copy Markdown
Contributor

This PR adds initial Bell support

API Changes

  • world.Viewer{}.ViewBlockUpdate now takes an additional nbtOnly bool parameter:
    • This allows callers to send block entity NBT updates without forcing a full block runtime update.
    • Bell: sending an packet.UpdateBlock on every ring tick causes the ringing animation to look weird.

Comment thread server/block/bell.go
}

// ring starts or refreshes the Bell ring state.
func (b Bell) ring(pos cube.Pos, tx *world.Tx, face cube.Face) bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be exposed so bells can be triggered through code?

Comment thread server/block/bell.go
Comment on lines +201 to +205
// multipleSupportFaces returns the faces checked for a Bell attached between two side supports.
func (b Bell) multipleSupportFaces() (cube.Face, cube.Face) {
face := b.Facing.Face()
return face, face.Opposite()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a whole method if it's used just once?

Comment thread server/block/bell.go
}

// bellFace returns a cube.Face from the given int32, or the fallback if the int32 is not a valid horizontal face.
func bellFace(v int32, fallback cube.Face) cube.Face {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this take an int32 and cast to a cube.Face when all but one callers go from a cube.Face to an int?

Comment thread server/block/bell.go
Comment on lines +176 to +184
if c.ItemDropChance < 0 {
return
}
if c.ItemDropChance < 1 && c.ItemDropChance <= rand.Float64() {
return
}
for _, drop := range b.BreakInfo().Drops(item.ToolNone{}, nil) {
dropItem(tx, drop, pos.Vec3Centre())
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be some sort of generic method on the explosion config if this logic has to be done for every block that handles explosion drops individually? Or is some of the logic here unique to bells

Comment thread server/block/bell.go

// Explode ...
func (b Bell) Explode(_ mgl64.Vec3, pos cube.Pos, tx *world.Tx, c ExplosionConfig) {
b.ring(pos, tx, b.Facing.Face())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right, I cannot replicate this in vanilla

Comment thread server/block/bell.go
Comment on lines +127 to +132
if b.ringTicks < 50 {
tx.SetBlock(pos, b, &world.SetOpts{DisableBlockUpdates: true, DisableLiquidDisplacement: true})
return
}
b.Toggle, b.ringTicks = false, 0
tx.SetBlock(pos, b, &world.SetOpts{DisableBlockUpdates: true, DisableLiquidDisplacement: true})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably simplify this?

b.ringTicks++
if b.ringTicks >= 50 {
	b.Toggle, b.ringTicks = false, 0
}
tx.SetBlock(pos, b, &world.SetOpts{DisableBlockUpdates: true, DisableLiquidDisplacement: true})

Comment thread server/block/bell.go

// Activate ...
func (b Bell) Activate(pos cube.Pos, face cube.Face, tx *world.Tx, _ item.User, _ *item.UseContext) bool {
return b.ring(pos, tx, face)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only ring when interacting with the correct axis

Comment thread server/world/viewer.go
Comment on lines 62 to 63
// ViewBlockUpdate views the updating of a block. It is called when a block is set at the position passed
// to the method.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document what nbtOnly is supposed to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants