forked from Tnze/go-mc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65699f0
commit 4b88f1f
Showing
51 changed files
with
619 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package provider | ||
|
||
import ( | ||
pk "github.com/Edouard127/go-mc/net/packet" | ||
"io" | ||
) | ||
|
||
type Abilities struct { | ||
Invulnerable bool | ||
Flying bool | ||
AllowFlying bool | ||
InstantBuild bool | ||
CanBuild bool | ||
FlyingSpeed float64 | ||
WalkingSpeed float64 | ||
} | ||
|
||
func NewAbilities() *Abilities { | ||
return &Abilities{CanBuild: true, FlyingSpeed: 0.05, WalkingSpeed: 0.1} | ||
} | ||
|
||
func (a *Abilities) ReadFrom(r io.Reader) (int64, error) { | ||
var flags pk.Byte | ||
var flyingSpeed pk.Float | ||
nn, err := pk.Tuple{flags, flyingSpeed}.ReadFrom(r) | ||
if err != nil { | ||
return nn, err | ||
} | ||
|
||
a.FlyingSpeed = float64(flyingSpeed) | ||
|
||
a.Invulnerable = flags&0x01 != 0 | ||
a.Flying = flags&0x02 != 0 | ||
a.AllowFlying = flags&0x04 != 0 | ||
a.InstantBuild = flags&0x08 != 0 | ||
|
||
return nn, nil | ||
} | ||
|
||
func (a *Abilities) WriteTo(w io.Writer) (int64, error) { | ||
var flags byte | ||
if a.Flying { | ||
flags |= 0x02 | ||
} | ||
return pk.Byte(flags).WriteTo(w) | ||
} |
Oops, something went wrong.