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

Add slime blocks #445

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions server/block/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/block/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func init() {
world.RegisterBlock(DeadBush{})
world.RegisterBlock(Snow{})
world.RegisterBlock(Bookshelf{})
world.RegisterBlock(SlimeBlock{})

registerAll(allBarrels())
registerAll(allBasalt())
Expand Down Expand Up @@ -259,6 +260,7 @@ func init() {
world.RegisterItem(SeaPickle{})
world.RegisterItem(Snow{})
world.RegisterItem(Bookshelf{})
world.RegisterItem(SlimeBlock{})
world.RegisterItem(Chain{})
world.RegisterItem(SandstoneStairs{})
world.RegisterItem(SandstoneStairs{Red: true})
Expand Down
39 changes: 39 additions & 0 deletions server/block/slime_block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package block

import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/world"
)

// SlimeBlock is a block that slows down entities and bounces them up if they drop onto it.
type SlimeBlock struct {
solid
transparent
}

// EntityLand ...
func (SlimeBlock) EntityLand(_ cube.Pos, _ *world.World, e world.Entity) {
if fallEntity, ok := e.(fallDistanceEntity); ok {
fallEntity.ResetFallDistance()
HashimTheArab marked this conversation as resolved.
Show resolved Hide resolved
}
}

// BreakInfo ...
func (s SlimeBlock) BreakInfo() BreakInfo {
return newBreakInfo(0, alwaysHarvestable, nothingEffective, oneOf(s))
}

// Friction ...
func (SlimeBlock) Friction() float64 {
return 0.8
}

// EncodeItem ...
func (SlimeBlock) EncodeItem() (name string, meta int16) {
return "minecraft:slime", 0
}

// EncodeBlock ...
func (SlimeBlock) EncodeBlock() (string, map[string]interface{}) {
return "minecraft:slime", nil
}