Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
跟进mc1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
BaiMeow committed Dec 11, 2021
1 parent a87c2d3 commit 4bfa79d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FishBot2

![minecraft version](https://img.shields.io/badge/Minecraft-1.17.1-green?style=flat)
![minecraft version](https://img.shields.io/badge/Minecraft-1.18-green?style=flat)
[![Go Report Card](https://goreportcard.com/badge/github.com/MscBaiMeow/FishBot2)](https://goreportcard.com/report/github.com/MscBaiMeow/FishBot2)

Minecraft钓鱼机器人
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/BaiMeow/msauth v0.0.0-20210912123815-8dad139b8658
github.com/Tnze/go-mc v1.17.1-0.20210806203433-99081e1b9cfb
github.com/Tnze/go-mc v1.17.2-0.20211211093242-38cc60ea6593
github.com/google/uuid v1.3.0
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ github.com/BaiMeow/msauth v0.0.0-20210912123815-8dad139b8658 h1:nBNOhUa62Lh7I/Pb
github.com/BaiMeow/msauth v0.0.0-20210912123815-8dad139b8658/go.mod h1:8aaR4Tp6OvyLjGc8zn5tcWZ3bS52LkDYgDmYEQMw2MY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Tnze/go-mc v1.17.1-0.20210806203433-99081e1b9cfb h1:jf5lM8mkIpYLFF2cORRGYVK9Mv/xuomG1hmR0b4EzXU=
github.com/Tnze/go-mc v1.17.1-0.20210806203433-99081e1b9cfb/go.mod h1:t0AI38F1BEmmy8/uLhr9RCOUeDbBj3oUNQH9akjzMc0=
github.com/Tnze/go-mc v1.17.2-0.20211211093242-38cc60ea6593 h1:ZA2NGCVITgX2OjvJ8vbQ9HwZkclJ/lkKVYGBVSwKGQA=
github.com/Tnze/go-mc v1.17.2-0.20211211093242-38cc60ea6593/go.mod h1:t0AI38F1BEmmy8/uLhr9RCOUeDbBj3oUNQH9akjzMc0=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down
26 changes: 14 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,25 @@ var (
vp *viper.Viper
)

var updatebobber = bot.PacketHandler{
ID: packetid.EntityMetadata,
var updateBobber = bot.PacketHandler{
ID: packetid.ClientboundSetEntityData,
Priority: 1,
F: checkbobber,
F: checkBobber,
}

var newentity = bot.PacketHandler{
ID: packetid.SpawnEntity,
var newEntity = bot.PacketHandler{
ID: packetid.ClientboundAddEntity,
Priority: 1,
F: newbobber,
F: newBobber,
}

//go:embed config.toml
var defaultConfig []byte

func main() {
log.SetOutput(colorable.NewColorableStdout())
log.Println("自动钓鱼机器人")
log.Println("版本号:mc1.18")
vp = viper.New()
vp.SetConfigName("config")
vp.SetConfigType("toml")
Expand Down Expand Up @@ -93,7 +95,7 @@ func main() {
ChatMsg: onChatMsg,
Disconnect: onDisconnect,
}.Attach(c)
c.Events.AddListener(updatebobber, newentity)
c.Events.AddListener(updateBobber, newEntity)
addr := net.JoinHostPort(vp.GetString("setting.ip"), strconv.Itoa(vp.GetInt("setting.port")))
for {
if err := c.JoinServer(addr); err != nil {
Expand Down Expand Up @@ -122,7 +124,7 @@ func onDisconnect(c chat.Message) error {
return nil
}

func checkbobber(p pk.Packet) error {
func checkBobber(p pk.Packet) error {
var EID pk.VarInt
p.Scan(&EID)
if int32(EID) != bobberID {
Expand All @@ -140,7 +142,7 @@ func checkbobber(p pk.Packet) error {
}
return nil
}
func newbobber(p pk.Packet) error {
func newBobber(p pk.Packet) error {
var (
EID pk.VarInt
UUID pk.UUID
Expand Down Expand Up @@ -186,7 +188,7 @@ func watchdog() {
}
}

func onChatMsg(msg chat.Message, pos byte, sender uuid.UUID) error {
func onChatMsg(msg chat.Message, _ byte, _ uuid.UUID) error {
log.Println(msg.ClearString())
return nil
}
Expand All @@ -203,12 +205,12 @@ func listenMsg() {
}

func useItem() error {
return c.Conn.WritePacket(pk.Packet{ID: packetid.UseItem, Data: []byte{0}})
return c.Conn.WritePacket(pk.Packet{ID: packetid.ServerboundUseItem, Data: []byte{0}})
}

func sendMsg(str string) error {
if str == "/throw" {
return useItem()
}
return c.Conn.WritePacket(pk.Marshal(packetid.ChatServerbound, pk.String(str)))
return c.Conn.WritePacket(pk.Marshal(packetid.ServerboundChat, pk.String(str)))
}

0 comments on commit 4bfa79d

Please sign in to comment.