mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Merge branch 'master' into 1.20.6
This commit is contained in:
commit
494be0930b
15 changed files with 455 additions and 1655 deletions
63
MinecraftClient/Mapping/DirectionExtensions.cs
Normal file
63
MinecraftClient/Mapping/DirectionExtensions.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
|
||||
namespace MinecraftClient.Mapping
|
||||
{
|
||||
public static class DirectionExtensions
|
||||
{
|
||||
public static Direction GetOpposite(this Direction direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.SouthEast:
|
||||
return Direction.NorthEast;
|
||||
case Direction.SouthWest:
|
||||
return Direction.NorthWest;
|
||||
|
||||
case Direction.NorthEast:
|
||||
return Direction.SouthEast;
|
||||
case Direction.NorthWest:
|
||||
return Direction.SouthWest;
|
||||
|
||||
case Direction.West:
|
||||
return Direction.East;
|
||||
case Direction.East:
|
||||
return Direction.West;
|
||||
|
||||
case Direction.North:
|
||||
return Direction.South;
|
||||
case Direction.South:
|
||||
return Direction.North;
|
||||
|
||||
case Direction.Down:
|
||||
return Direction.Up;
|
||||
case Direction.Up:
|
||||
return Direction.Down;
|
||||
default:
|
||||
return Direction.Up;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Direction[] HORIZONTAL =
|
||||
{
|
||||
Direction.South,
|
||||
Direction.West,
|
||||
Direction.North,
|
||||
Direction.East
|
||||
};
|
||||
|
||||
public static Direction FromRotation(double rotation)
|
||||
{
|
||||
double floor = Math.Floor((rotation / 90.0) + 0.5);
|
||||
int value = (int)floor & 3;
|
||||
|
||||
return FromHorizontal(value);
|
||||
}
|
||||
|
||||
public static Direction FromHorizontal(int value)
|
||||
{
|
||||
return HORIZONTAL[Math.Abs(value % HORIZONTAL.Length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ namespace MinecraftClient.Mapping
|
|||
/// <summary>
|
||||
/// The dimension info of the world
|
||||
/// </summary>
|
||||
private static Dimension curDimension = new();
|
||||
private static Dimension curDimension= new();
|
||||
|
||||
private static readonly Dictionary<string, Dimension> dimensionList = new();
|
||||
|
||||
|
|
@ -230,10 +230,32 @@ namespace MinecraftClient.Mapping
|
|||
/// </summary>
|
||||
/// <param name="name"> The name of the dimension type</param>
|
||||
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
|
||||
public static void SetDimension(string name)
|
||||
{
|
||||
curDimension = dimensionList[name]; // Should not fail
|
||||
}
|
||||
public static void SetDimension(string name)
|
||||
{
|
||||
// Try to get the dimension using the name as is
|
||||
if (dimensionList.TryGetValue(name, out Dimension dimension))
|
||||
{
|
||||
curDimension = dimension;
|
||||
return; // Dimension found
|
||||
}
|
||||
|
||||
// If not found, check if name lacks 'minecraft:' prefix and try again
|
||||
if (!name.StartsWith("minecraft:"))
|
||||
{
|
||||
string prefixedName = "minecraft:" + name;
|
||||
if (dimensionList.TryGetValue(prefixedName, out dimension))
|
||||
{
|
||||
curDimension = dimension;
|
||||
return; // Dimension found with prefixed name
|
||||
}
|
||||
}
|
||||
|
||||
// If still not found, dimension does not exist
|
||||
throw new KeyNotFoundException($"Dimension '{name}' not found in dimensions dictionary.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get current dimension
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue