mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Another fix for #2159
This commit is contained in:
parent
7e71fbf241
commit
8ce5c40b28
2 changed files with 35 additions and 9 deletions
|
|
@ -21,9 +21,9 @@ namespace MinecraftClient.Mapping
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The dimension info of the world
|
/// The dimension info of the world
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static Dimension curDimension = new Dimension();
|
private static Dimension curDimension = new();
|
||||||
|
|
||||||
private static Dictionary<string, Dimension>? dimensionList = null;
|
private static Dictionary<string, Dimension> dimensionList = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Chunk data parsing progress
|
/// Chunk data parsing progress
|
||||||
|
|
@ -61,16 +61,29 @@ namespace MinecraftClient.Mapping
|
||||||
/// <param name="registryCodec">Registry Codec nbt data</param>
|
/// <param name="registryCodec">Registry Codec nbt data</param>
|
||||||
public static void StoreDimensionList(Dictionary<string, object> registryCodec)
|
public static void StoreDimensionList(Dictionary<string, object> registryCodec)
|
||||||
{
|
{
|
||||||
dimensionList = new();
|
|
||||||
var dimensionListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:dimension_type"])["value"]);
|
var dimensionListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:dimension_type"])["value"]);
|
||||||
foreach (Dictionary<string, object> dimensionNbt in dimensionListNbt)
|
foreach (Dictionary<string, object> dimensionNbt in dimensionListNbt)
|
||||||
{
|
{
|
||||||
string dimensionName = (string)dimensionNbt["name"];
|
string dimensionName = (string)dimensionNbt["name"];
|
||||||
Dictionary<string, object> element = (Dictionary<string, object>)dimensionNbt["element"];
|
Dictionary<string, object> element = (Dictionary<string, object>)dimensionNbt["element"];
|
||||||
|
if (dimensionList.ContainsKey(dimensionName))
|
||||||
|
dimensionList.Remove(dimensionName);
|
||||||
dimensionList.Add(dimensionName, new Dimension(dimensionName, element));
|
dimensionList.Add(dimensionName, new Dimension(dimensionName, element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Store one dimension - 1.16.2 to 1.18.2
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dimensionName">Dimension name</param>
|
||||||
|
/// <param name="dimensionType">Dimension Type nbt data</param>
|
||||||
|
public static void StoreDimension(string dimensionName, Dictionary<string, object> dimensionType)
|
||||||
|
{
|
||||||
|
if (dimensionList.ContainsKey(dimensionName))
|
||||||
|
dimensionList.Remove(dimensionName);
|
||||||
|
dimensionList.Add(dimensionName, new Dimension(dimensionName, dimensionType));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set current dimension - 1.16 and above
|
/// Set current dimension - 1.16 and above
|
||||||
|
|
@ -79,7 +92,7 @@ namespace MinecraftClient.Mapping
|
||||||
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
|
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
|
||||||
public static void SetDimension(string name)
|
public static void SetDimension(string name)
|
||||||
{
|
{
|
||||||
curDimension = dimensionList![name]; // Should not fail
|
curDimension = dimensionList[name]; // Should not fail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
for (int i = 0; i < worldCount; i++)
|
for (int i = 0; i < worldCount; i++)
|
||||||
dataTypes.ReadNextString(packetData); // Dimension Names (World Names) - 1.16 and above
|
dataTypes.ReadNextString(packetData); // Dimension Names (World Names) - 1.16 and above
|
||||||
var registryCodec = dataTypes.ReadNextNbt(packetData); // Registry Codec (Dimension Codec) - 1.16 and above
|
var registryCodec = dataTypes.ReadNextNbt(packetData); // Registry Codec (Dimension Codec) - 1.16 and above
|
||||||
World.StoreDimensionList(registryCodec);
|
if (handler.GetTerrainEnabled())
|
||||||
|
World.StoreDimensionList(registryCodec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current dimension
|
// Current dimension
|
||||||
|
|
@ -380,12 +381,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// String identifier: 1.16 and 1.16.1
|
// String identifier: 1.16 and 1.16.1
|
||||||
// varInt: [1.9.1 to 1.15.2]
|
// varInt: [1.9.1 to 1.15.2]
|
||||||
// byte: below 1.9.1
|
// byte: below 1.9.1
|
||||||
|
Dictionary<string, object>? dimensionType = null;
|
||||||
if (protocolVersion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
if (protocolVersion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||||
else if (protocolVersion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
dimensionType = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
||||||
else
|
else
|
||||||
dataTypes.ReadNextString(packetData);
|
dataTypes.ReadNextString(packetData);
|
||||||
this.currentDimension = 0;
|
this.currentDimension = 0;
|
||||||
|
|
@ -401,7 +403,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (protocolVersion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||||
World.SetDimension(dimensionName);
|
if (handler.GetTerrainEnabled())
|
||||||
|
{
|
||||||
|
if (protocolVersion >= MC_1_16_2_Version && protocolVersion < MC_1_19_Version)
|
||||||
|
World.StoreDimension(dimensionName, dimensionType!);
|
||||||
|
World.SetDimension(dimensionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolVersion >= MC_1_15_Version)
|
if (protocolVersion >= MC_1_15_Version)
|
||||||
|
|
@ -594,12 +601,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.Respawn:
|
case PacketTypesIn.Respawn:
|
||||||
|
Dictionary<string, object>? dimensionTypeRespawn = null;
|
||||||
if (protocolVersion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
if (protocolVersion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||||
else if (protocolVersion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
dimensionTypeRespawn = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
||||||
else
|
else
|
||||||
dataTypes.ReadNextString(packetData);
|
dataTypes.ReadNextString(packetData);
|
||||||
this.currentDimension = 0;
|
this.currentDimension = 0;
|
||||||
|
|
@ -612,7 +620,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (protocolVersion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||||
World.SetDimension(dimensionName);
|
if (handler.GetTerrainEnabled())
|
||||||
|
{
|
||||||
|
if (protocolVersion >= MC_1_16_2_Version && protocolVersion < MC_1_19_Version)
|
||||||
|
World.StoreDimension(dimensionName, dimensionTypeRespawn!);
|
||||||
|
World.SetDimension(dimensionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolVersion < MC_1_14_Version)
|
if (protocolVersion < MC_1_14_Version)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue