fix code format
This commit is contained in:
@ -2,10 +2,11 @@ package server
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"github.com/Tnze/go-mc/server/auth"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/Tnze/go-mc/net"
|
||||
"github.com/Tnze/go-mc/server/auth"
|
||||
)
|
||||
|
||||
type GamePlay interface {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package bvh
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/constraints"
|
||||
"math"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
type AABB[I constraints.Signed | constraints.Float, V interface {
|
||||
@ -18,10 +19,12 @@ type AABB[I constraints.Signed | constraints.Float, V interface {
|
||||
func (aabb AABB[I, V]) WithIn(point V) bool {
|
||||
return aabb.Lower.Less(point) && aabb.Upper.More(point)
|
||||
}
|
||||
|
||||
func (aabb AABB[I, V]) Touch(other AABB[I, V]) bool {
|
||||
return aabb.Lower.Less(other.Upper) && other.Lower.Less(aabb.Upper) &&
|
||||
aabb.Upper.More(other.Lower) && other.Upper.More(aabb.Lower)
|
||||
}
|
||||
|
||||
func (aabb AABB[I, V]) Union(other AABB[I, V]) AABB[I, V] {
|
||||
return AABB[I, V]{Upper: aabb.Upper.Max(other.Upper), Lower: aabb.Lower.Min(other.Lower)}
|
||||
}
|
||||
@ -45,9 +48,11 @@ type Sphere[I constraints.Float, V interface {
|
||||
func (s Sphere[I, V]) WithIn(point V) bool {
|
||||
return s.Center.Sub(point).Norm() < s.R
|
||||
}
|
||||
|
||||
func (s Sphere[I, V]) Touch(other Sphere[I, V]) bool {
|
||||
return s.Center.Sub(other.Center).Norm() < s.R+other.R
|
||||
}
|
||||
|
||||
func (s Sphere[I, V]) Union(other Sphere[I, V]) Sphere[I, V] {
|
||||
d := other.Center.Sub(s.Center).Norm()
|
||||
r1r2d := (s.R - other.R) / d
|
||||
|
@ -58,9 +58,9 @@ func TestTree2_Find_vec(t *testing.T) {
|
||||
t.Log(find(TouchPoint[Vec2d, AABBVec2d](Vec2d{1.5, 1.5})))
|
||||
t.Log(find(TouchPoint[Vec2d, AABBVec2d](Vec2d{-1.5, 0})))
|
||||
|
||||
t.Log(find(TouchBound[AABBVec2d](AABBVec2d{Upper: Vec2d{1, 1}, Lower: Vec2d{-1, -1}})))
|
||||
t.Log(find(TouchBound[AABBVec2d](AABBVec2d{Upper: Vec2d{1, 1}, Lower: Vec2d{1.5, 1.5}})))
|
||||
t.Log(find(TouchBound[AABBVec2d](AABBVec2d{Upper: Vec2d{-1.5, 0.5}, Lower: Vec2d{-2.5, -0.5}})))
|
||||
t.Log(find(TouchBound(AABBVec2d{Upper: Vec2d{1, 1}, Lower: Vec2d{-1, -1}})))
|
||||
t.Log(find(TouchBound(AABBVec2d{Upper: Vec2d{1, 1}, Lower: Vec2d{1.5, 1.5}})))
|
||||
t.Log(find(TouchBound(AABBVec2d{Upper: Vec2d{-1.5, 0.5}, Lower: Vec2d{-2.5, -0.5}})))
|
||||
}
|
||||
|
||||
func BenchmarkTree_Insert(b *testing.B) {
|
||||
|
@ -4,8 +4,9 @@ import (
|
||||
"container/list"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Tnze/go-mc/chat"
|
||||
"time"
|
||||
|
||||
"github.com/Tnze/go-mc/chat"
|
||||
)
|
||||
|
||||
// keepAliveInterval represents the interval when the server sends keep alive
|
||||
|
@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Tnze/go-mc/chat"
|
||||
"github.com/Tnze/go-mc/data/packetid"
|
||||
"github.com/Tnze/go-mc/net"
|
||||
@ -51,7 +52,7 @@ type MojangLoginHandler struct {
|
||||
|
||||
// AcceptLogin implement LoginHandler for MojangLoginHandler
|
||||
func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name string, id uuid.UUID, profilePubKey *auth.PublicKey, properties []auth.Property, err error) {
|
||||
//login start
|
||||
// login start
|
||||
var p pk.Packet
|
||||
err = conn.ReadPacket(&p)
|
||||
if err != nil {
|
||||
@ -69,7 +70,7 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
|
||||
profileUUID pk.UUID // ignored
|
||||
)
|
||||
err = p.Scan(
|
||||
(*pk.String)(&name), //decode username as pk.String
|
||||
(*pk.String)(&name), // decode username as pk.String
|
||||
&hasPubKey, pk.Opt{
|
||||
Has: &hasPubKey,
|
||||
Field: &pubKey,
|
||||
@ -94,10 +95,10 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
|
||||
return
|
||||
}
|
||||
|
||||
//auth
|
||||
// auth
|
||||
if d.OnlineMode {
|
||||
var resp *auth.Resp
|
||||
//Auth, Encrypt
|
||||
// Auth, Encrypt
|
||||
resp, err = auth.Encrypt(conn, name, pubKey.PubKey)
|
||||
if err != nil {
|
||||
return
|
||||
@ -110,7 +111,7 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
|
||||
id = offline.NameToUUID(name)
|
||||
}
|
||||
|
||||
//set compression
|
||||
// set compression
|
||||
if d.Threshold >= 0 {
|
||||
err = conn.WritePacket(pk.Marshal(
|
||||
packetid.LoginCompression,
|
||||
|
@ -28,14 +28,17 @@ package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/Tnze/go-mc/data/packetid"
|
||||
"github.com/Tnze/go-mc/net"
|
||||
pk "github.com/Tnze/go-mc/net/packet"
|
||||
"log"
|
||||
)
|
||||
|
||||
const ProtocolName = "1.19.2"
|
||||
const ProtocolVersion = 760
|
||||
const (
|
||||
ProtocolName = "1.19.2"
|
||||
ProtocolVersion = 760
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
*log.Logger
|
||||
|
Reference in New Issue
Block a user