From a306a6e77fbe9f47848fccd7cf72129e1bf2b54f Mon Sep 17 00:00:00 2001 From: olebeck <31539311+olebeck@users.noreply.github.com> Date: Sun, 5 Feb 2023 17:41:06 +0100 Subject: [PATCH] fix map item --- go.mod | 2 +- subcommands/world/map_item.go | 18 +++++++++++++++++- subcommands/world/world.go | 4 +++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5cb0cf3..8a2ca2a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ go 1.19 replace github.com/sandertv/gophertunnel => github.com/olebeck/gophertunnel v1.26.2 //replace github.com/df-mc/dragonfly => ./dragonfly -replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.9.1-10 +replace github.com/df-mc/dragonfly => github.com/olebeck/dragonfly v0.9.1-11 require ( github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 diff --git a/subcommands/world/map_item.go b/subcommands/world/map_item.go index 80e4e98..c344b59 100644 --- a/subcommands/world/map_item.go +++ b/subcommands/world/map_item.go @@ -34,7 +34,8 @@ var MapItemPacket packet.InventoryContent = packet.InventoryContent{ BlockRuntimeID: 0, Count: 1, NBTData: map[string]interface{}{ - "map_uuid": int64(ViewMapID), + "map_name_index": int64(1), + "map_uuid": int64(ViewMapID), }, }, }, @@ -89,6 +90,20 @@ func NewMapUI(w *WorldState) *MapUI { } func (m *MapUI) Start() { + // init map + if err := m.w.proxy.Client.WritePacket(&packet.ClientBoundMapItemData{ + MapID: ViewMapID, + Scale: 4, + MapsIncludedIn: []int64{ViewMapID}, + Width: 0, + Height: 0, + Pixels: nil, + UpdateFlags: packet.MapUpdateFlagInitialisation, + }); err != nil { + logrus.Error(err) + return + } + m.ticker = time.NewTicker(33 * time.Millisecond) go func() { for range m.ticker.C { @@ -99,6 +114,7 @@ func (m *MapUI) Start() { if m.w.proxy.Client != nil { if err := m.w.proxy.Client.WritePacket(&packet.ClientBoundMapItemData{ MapID: ViewMapID, + Scale: 4, Width: 128, Height: 128, Pixels: utils.Img2rgba(m.img), diff --git a/subcommands/world/world.go b/subcommands/world/world.go index a71dc54..5fb6815 100644 --- a/subcommands/world/world.go +++ b/subcommands/world/world.go @@ -411,7 +411,9 @@ func (w *WorldState) SaveAndReset() { Version: p.Manifest().Header.Version, }) } - addPacksJSON("world_resource_packs.json", rdeps) + if len(rdeps) > 0 { + addPacksJSON("world_resource_packs.json", rdeps) + } } }