Skip to content

Commit b5d0db5

Browse files
committed
map fixes
1 parent 815b57d commit b5d0db5

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

src/MiNET/MiNET/Entities/World/MapEntity.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class MapEntity : Entity
3737
private static readonly ILog Log = LogManager.GetLogger(typeof(MapEntity));
3838

3939
public MapInfo MapInfo { get; set; }
40+
public bool initialized { get; set; } = false;
4041
public IMapImageProvider ImageProvider { get; set; }
4142

4243
public MapEntity(Level level, long mapId = EntityManager.EntityIdUndefined) : base(EntityType.None, level)
@@ -56,7 +57,7 @@ public MapEntity(Level level, long mapId = EntityManager.EntityIdUndefined) : ba
5657
var mapInfo = new MapInfo
5758
{
5859
MapId = EntityId,
59-
UpdateType = 6,
60+
UpdateType = 0,
6061
Scale = 0,
6162
X = 0,
6263
Z = 0,
@@ -107,12 +108,15 @@ public override void OnTick(Entity[] entities)
107108
if (data != null)
108109
{
109110
MapInfo.Data = data;
111+
112+
MapInfo.UpdateType = initialized ? (byte) 2 : (byte) 8;
113+
110114
var mapInfo = (MapInfo) MapInfo.Clone();
111115

112116
var msg = McpeClientboundMapItemData.CreateObject();
113117
msg.mapinfo = mapInfo;
114118
Level.RelayBroadcast(msg);
115-
119+
initialized = true;
116120
return;
117121
}
118122

src/MiNET/MiNET/Net/MCPE Protocol.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5897,6 +5897,7 @@ public partial class McpeMapInfoRequest : Packet<McpeMapInfoRequest>
58975897
{
58985898

58995899
public long mapId; // = null;
5900+
public pixelList pixellist; // = null;
59005901

59015902
public McpeMapInfoRequest()
59025903
{
@@ -5911,6 +5912,7 @@ protected override void EncodePacket()
59115912
BeforeEncode();
59125913

59135914
WriteSignedVarLong(mapId);
5915+
WriteUnsignedVarInt(0);
59145916

59155917
AfterEncode();
59165918
}
@@ -5925,6 +5927,7 @@ protected override void DecodePacket()
59255927
BeforeDecode();
59265928

59275929
mapId = ReadSignedVarLong();
5930+
pixellist = ReadPixelList();
59285931

59295932
AfterDecode();
59305933
}
@@ -5937,6 +5940,7 @@ protected override void ResetPacket()
59375940
base.ResetPacket();
59385941

59395942
mapId=default(long);
5943+
pixellist = default(pixelList);
59405944
}
59415945

59425946
}

src/MiNET/MiNET/Net/Packet.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,8 +3182,8 @@ public void Write(MapInfo map)
31823182

31833183
if ((map.UpdateType & MapUpdateFlagInitialisation) != 0)
31843184
{
3185-
WriteUnsignedVarInt(0);
3186-
//WriteSignedVarLong(map.MapId);
3185+
WriteUnsignedVarInt(1);
3186+
WriteSignedVarLong(map.MapId);
31873187
}
31883188

31893189
if ((map.UpdateType & (MapUpdateFlagInitialisation | MapUpdateFlagDecoration | MapUpdateFlagTexture)) != 0)
@@ -3404,6 +3404,18 @@ public MapInfo ReadMapInfo()
34043404
return map;
34053405
}
34063406

3407+
public pixelList ReadPixelList()
3408+
{
3409+
pixelList mapData = new pixelList();
3410+
3411+
var listSize = ReadInt();
3412+
for (int i = 0; i < listSize; i++)
3413+
{
3414+
mapData.mapData.Add(new pixels { pixel = ReadUnsignedVarInt(), index = ReadShort()});
3415+
}
3416+
return mapData;
3417+
}
3418+
34073419
public void Write(ScoreEntries list)
34083420
{
34093421
if (list == null) list = new ScoreEntries();

src/MiNET/MiNET/Utils/pixelList.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace MiNET.Utils
4+
{
5+
public class pixelList
6+
{
7+
public List<pixels> mapData = new List<pixels>();
8+
}
9+
public class pixels
10+
{
11+
public uint pixel;
12+
public short index;
13+
}
14+
}

0 commit comments

Comments
 (0)