diff --git a/block/bounce.go b/block/bounce.go index 6d68f6f..49687f7 100644 --- a/block/bounce.go +++ b/block/bounce.go @@ -14,12 +14,13 @@ func (slime) Matches(b world.Block, name string) bool { return name == "minecraft:slime" } -func (slime) Apply(s *resolution) { +func (slime) Apply(s resolution) resolution { if !s.groundFrictionSet { s.GroundFriction = 0.8 s.groundFrictionSet = true } s.Bounce = BounceSlime + return s } type bed struct{} @@ -31,6 +32,7 @@ func (bed) Matches(b world.Block, name string) bool { return name == "minecraft:bed" } -func (bed) Apply(s *resolution) { +func (bed) Apply(s resolution) resolution { s.Bounce = BounceBed + return s } diff --git a/block/climbable.go b/block/climbable.go index 5bb0f9b..504b525 100644 --- a/block/climbable.go +++ b/block/climbable.go @@ -21,6 +21,7 @@ func (climbableBlock) Matches(b world.Block, name string) bool { } } -func (climbableBlock) Apply(s *resolution) { +func (climbableBlock) Apply(s resolution) resolution { s.Climbable = true + return s } diff --git a/block/contact.go b/block/contact.go index b650331..aeda985 100644 --- a/block/contact.go +++ b/block/contact.go @@ -8,6 +8,7 @@ func (cobweb) Matches(_ world.Block, name string) bool { return name == "minecraft:web" } -func (cobweb) Apply(s *resolution) { +func (cobweb) Apply(s resolution) resolution { s.Cobweb = true + return s } diff --git a/block/environment.go b/block/environment.go index e22cf33..1e342d7 100644 --- a/block/environment.go +++ b/block/environment.go @@ -13,8 +13,9 @@ func (r environmentRule) Matches(_ world.Block, name string) bool { return name == r.name } -func (r environmentRule) Apply(s *resolution) { +func (r environmentRule) Apply(s resolution) resolution { s.InsideMovement = r.inside s.Traversal = r.traversal s.Honey = r.honey + return s } diff --git a/block/friction.go b/block/friction.go index 395fa33..f2154a2 100644 --- a/block/friction.go +++ b/block/friction.go @@ -11,9 +11,10 @@ func (b frictionBlock) Matches(_ world.Block, name string) bool { return name == b.name } -func (b frictionBlock) Apply(s *resolution) { +func (b frictionBlock) Apply(s resolution) resolution { if !s.groundFrictionSet { s.GroundFriction = b.friction s.groundFrictionSet = true } + return s } diff --git a/block/ground.go b/block/ground.go index 3db425a..dd98673 100644 --- a/block/ground.go +++ b/block/ground.go @@ -14,7 +14,8 @@ func (soulSand) Matches(b world.Block, name string) bool { return name == "minecraft:soul_sand" } -func (soulSand) Apply(s *resolution) { +func (soulSand) Apply(s resolution) resolution { s.GroundAccelerationFrictionMultiplier *= SoulSandAccelerationFrictionMultiplier s.SoulSpeedNeutralizesAccelerationFriction = true + return s } diff --git a/block/semantics.go b/block/semantics.go index 09fd3e7..da842e3 100644 --- a/block/semantics.go +++ b/block/semantics.go @@ -56,7 +56,7 @@ type MovementSemantics struct { // rule contributes movement behavior for a block family. type rule interface { Matches(world.Block, string) bool - Apply(*resolution) + Apply(resolution) resolution } type resolution struct { @@ -92,7 +92,7 @@ func Resolve(b world.Block, name string) MovementSemantics { } for _, rule := range rules { if rule.Matches(b, name) { - rule.Apply(&result) + result = rule.Apply(result) } } if !result.groundFrictionSet { diff --git a/block/semantics_test.go b/block/semantics_test.go index de9983c..0403704 100644 --- a/block/semantics_test.go +++ b/block/semantics_test.go @@ -15,9 +15,10 @@ func (r *countingRule) Matches(world.Block, string) bool { return true } -func (*countingRule) Apply(s *resolution) { +func (*countingRule) Apply(s resolution) resolution { s.GroundFriction = 0.7 s.groundFrictionSet = true + return s } func TestResolveVisitsEachRuleOnce(t *testing.T) {