Skip to content

Commit

Permalink
fix dimension registry handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed Jun 15, 2024
1 parent bbb19c3 commit 73717c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bot/basic/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// WorldInfo content player info in server.
type WorldInfo struct {
DimensionType string
DimensionType int32
DimensionNames []string // Identifiers for all worlds on the server.
DimensionName string // Name of the world being spawned into.
HashedSeed int64 // First 8 bytes of the SHA-256 hash of the world's seed. Used client side for biome noise
Expand Down Expand Up @@ -41,7 +41,7 @@ func (p *Player) handleLoginPacket(packet pk.Packet) error {
(*pk.Boolean)(&p.ReducedDebugInfo),
(*pk.Boolean)(&p.EnableRespawnScreen),
(*pk.Boolean)(&p.DoLimitCrafting),
(*pk.Identifier)(&p.WorldInfo.DimensionType),
(*pk.VarInt)(&p.WorldInfo.DimensionType),
(*pk.Identifier)(&p.DimensionName),
(*pk.Long)(&p.HashedSeed),
(*pk.UnsignedByte)(&p.Gamemode),
Expand Down Expand Up @@ -84,7 +84,7 @@ func (p *Player) handleLoginPacket(packet pk.Packet) error {
func (p *Player) handleRespawnPacket(packet pk.Packet) error {
var copyMeta bool
err := packet.Scan(
(*pk.String)(&p.DimensionType),
(*pk.VarInt)(&p.DimensionType),
(*pk.Identifier)(&p.DimensionName),
(*pk.Long)(&p.HashedSeed),
(*pk.UnsignedByte)(&p.Gamemode),
Expand Down
6 changes: 3 additions & 3 deletions bot/world/chunks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world

import (
"errors"
"fmt"

"github.com/Tnze/go-mc/bot"
"github.com/Tnze/go-mc/bot/basic"
Expand Down Expand Up @@ -41,9 +41,9 @@ func (w *World) onPlayerSpawn(pk.Packet) error {

func (w *World) handleLevelChunkWithLightPacket(packet pk.Packet) error {
var pos level.ChunkPos
_, currentDimType := w.c.Registries.DimensionType.Find(w.p.DimensionType)
currentDimType := w.c.Registries.DimensionType.FindByID(w.p.DimensionType)
if currentDimType == nil {
return errors.New("dimension type " + w.p.DimensionType + " not found")
return fmt.Errorf("dimension type %d not found", w.p.DimensionType)
}
chunk := level.EmptyChunk(int(currentDimType.Height) / 16)
if err := packet.Scan(&pos, chunk); err != nil {
Expand Down

0 comments on commit 73717c3

Please sign in to comment.