afk/cook.go

65 lines
1.5 KiB
Go

package main
import (
"time"
"github.com/Tnze/go-mc/data/block"
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/net/packet"
"github.com/rs/zerolog/log"
)
func (c *Client) cook() {
has := false
// Set selected slot to last
if err := c.minecraft.Conn.WritePacket(packet.Marshal(
packetid.ServerboundSetCarriedItem,
packet.Short(8),
)); err != nil {
log.Err(err).Msg("")
}
<-time.After(time.Millisecond * 500)
// For slot 9-44 (inventory)
for slot := 9; slot <= 44; slot++ {
// For an entire stack
for count := 1; count <= 64; count += 4 {
// Four on the campfire at a time
for idx := 0; idx < 4; idx++ {
if err := c.minecraft.Conn.WritePacket(packet.Marshal(
packetid.ServerboundInteract,
packet.VarInt(block.Campfire.ID),
packet.VarInt(0),
packet.Opt{Has: &has},
packet.Opt{Has: &has},
packet.Opt{Has: &has},
packet.VarInt(0),
packet.Boolean(false),
)); err != nil {
log.Err(err).Msg("")
}
//if err := c.minecraft.Conn.WritePacket(packet.Marshal(
// packetid.ServerboundUseItem,
// packet.VarInt(0),
//)); err != nil {
// log.Err(err).Msg("")
//}
<-time.After(time.Millisecond * 500)
}
log.Info().Msg("waiting for cook")
// Campfire takes 30 seconds to cook, give short buffer
<-time.After(time.Second * 35)
}
// Pick the next slot
if err := c.minecraft.Conn.WritePacket(packet.Marshal(
packetid.ServerboundPickItem,
packet.VarInt(slot),
)); err != nil {
log.Err(err).Msg("")
}
<-time.After(time.Millisecond * 500)
}
}