look at the code if you want to know what i did

This commit is contained in:
adman
2026-03-22 00:35:07 +01:00
parent a6102b7ec9
commit ea024fe808
21 changed files with 294 additions and 78 deletions
+16 -3
View File
@@ -1,6 +1,7 @@
package print_nbt
import (
"bytes"
"encoding/json"
"flag"
"os"
@@ -9,8 +10,9 @@ import (
)
var (
cmd = flag.NewFlagSet("print-nbt", flag.ContinueOnError)
FileFlag = cmd.String("file", "", "The NBT file to print")
cmd = flag.NewFlagSet("print-nbt", flag.ContinueOnError)
FileFlag = cmd.String("file", "", "The NBT file to print")
HashFormatFlag = cmd.Bool("snbt", false, "will print with go %#v")
)
func Run(args []string) (err error) {
@@ -27,7 +29,18 @@ func Run(args []string) (err error) {
if err != nil {
return
}
b, err := json.MarshalIndent(n, "", " ")
var b []byte
if *HashFormatFlag {
bb := bytes.NewBuffer(nil)
err = nbt.PrintSNBTAny(n.Value, bb)
if err != nil {
return
}
b = bb.Bytes()
//b = []byte(strings.ReplaceAll(string(b), ",", ",\n"))
} else {
b, err = json.MarshalIndent(n, "", " ")
}
if err != nil {
return
}
+3 -6
View File
@@ -116,10 +116,7 @@ func handleClient(c *proto.Conn) (err error) {
return
}
defer sockPuppet.Close()
err = sockPuppet.Start(&client.LoginClient{
Conn: sockPuppet,
Account: acc,
})
err = sockPuppet.StartLoop()
if err != nil {
return
}
@@ -127,10 +124,10 @@ func handleClient(c *proto.Conn) (err error) {
p := &Proxy{Client: sockPuppet, Servee: c}
p.Data.Value = map[string]any{"Registries": []any{}}
go func() {
errChan <- p.Client.Start(p)
errChan <- p.Client.StartLoop()
}()
go func() {
errChan <- p.Servee.Start(p)
errChan <- p.Servee.StartLoop()
}()
err = <-errChan
f, err := os.Create("data/registry/" + SaveAs + ".nbt")
+2 -2
View File
@@ -154,10 +154,10 @@ func main() {
errChan := make(chan error)
defer pc.Close()
go func() {
errChan <- pc.Start(pc)
errChan <- pc.StartConn()
}()
go func() {
errChan <- p.Start(p)
errChan <- p.StartConn()
}()
err = <-errChan
return