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>
|
||||
/// The dimension info of the world
|
||||
/// </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>
|
||||
/// Chunk data parsing progress
|
||||
|
|
@ -61,16 +61,29 @@ namespace MinecraftClient.Mapping
|
|||
/// <param name="registryCodec">Registry Codec nbt data</param>
|
||||
public static void StoreDimensionList(Dictionary<string, object> registryCodec)
|
||||
{
|
||||
dimensionList = new();
|
||||
var dimensionListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:dimension_type"])["value"]);
|
||||
foreach (Dictionary<string, object> dimensionNbt in dimensionListNbt)
|
||||
{
|
||||
string dimensionName = (string)dimensionNbt["name"];
|
||||
Dictionary<string, object> element = (Dictionary<string, object>)dimensionNbt["element"];
|
||||
if (dimensionList.ContainsKey(dimensionName))
|
||||
dimensionList.Remove(dimensionName);
|
||||
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>
|
||||
/// Set current dimension - 1.16 and above
|
||||
|
|
@ -79,7 +92,7 @@ namespace MinecraftClient.Mapping
|
|||
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
|
||||
public static void SetDimension(string name)
|
||||
{
|
||||
curDimension = dimensionList![name]; // Should not fail
|
||||
curDimension = dimensionList[name]; // Should not fail
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -371,6 +371,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
for (int i = 0; i < worldCount; i++)
|
||||
dataTypes.ReadNextString(packetData); // Dimension Names (World Names) - 1.16 and above
|
||||
var registryCodec = dataTypes.ReadNextNbt(packetData); // Registry Codec (Dimension Codec) - 1.16 and above
|
||||
if (handler.GetTerrainEnabled())
|
||||
World.StoreDimensionList(registryCodec);
|
||||
}
|
||||
|
||||
|
|
@ -380,12 +381,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// String identifier: 1.16 and 1.16.1
|
||||
// varInt: [1.9.1 to 1.15.2]
|
||||
// byte: below 1.9.1
|
||||
Dictionary<string, object>? dimensionType = null;
|
||||
if (protocolVersion >= MC_1_16_Version)
|
||||
{
|
||||
if (protocolVersion >= MC_1_19_Version)
|
||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||
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
|
||||
dataTypes.ReadNextString(packetData);
|
||||
this.currentDimension = 0;
|
||||
|
|
@ -401,8 +403,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (protocolVersion >= MC_1_16_Version)
|
||||
{
|
||||
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||
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)
|
||||
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
|
||||
|
|
@ -594,12 +601,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
break;
|
||||
case PacketTypesIn.Respawn:
|
||||
Dictionary<string, object>? dimensionTypeRespawn = null;
|
||||
if (protocolVersion >= MC_1_16_Version)
|
||||
{
|
||||
if (protocolVersion >= MC_1_19_Version)
|
||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||
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
|
||||
dataTypes.ReadNextString(packetData);
|
||||
this.currentDimension = 0;
|
||||
|
|
@ -612,8 +620,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (protocolVersion >= MC_1_16_Version)
|
||||
{
|
||||
string dimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||
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)
|
||||
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue