fix map item

This commit is contained in:
olebeck 2023-02-05 17:41:06 +01:00
parent a601cb33a0
commit a306a6e77f
3 changed files with 21 additions and 3 deletions

2
go.mod
View File

@ -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

View File

@ -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),

View File

@ -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)
}
}
}