2022-07-24 21:41:56 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The dimension type, available after 1.16.2
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class Dimension
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The name of the dimension type (for example, "minecraft:overworld").
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public readonly string Name;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether piglins shake and transform to zombified piglins.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool piglinSafe = false;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
/// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins.
|
2022-07-24 21:41:56 +08:00
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool natural = true;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// How much light the dimension has.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly float ambientLight = 0.0f;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// If set, the time of the day is the specified value.
|
|
|
|
|
|
/// Value: -1: not set
|
|
|
|
|
|
/// Value: [0, 24000]: time of the day
|
|
|
|
|
|
/// </summary>
|
2022-07-24 21:48:09 +08:00
|
|
|
|
public readonly long fixedTime = -1;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A resource location defining what block tag to use for infiniburn.
|
2022-08-18 20:58:49 +02:00
|
|
|
|
/// Value above 1.18.2: "#" or minecraft resource "#minecraft:...".
|
|
|
|
|
|
/// Value below 1.18.1: "" or minecraft resource "minecraft:...".
|
2022-07-24 21:41:56 +08:00
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly string infiniburn = "#minecraft:infiniburn_overworld";
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether players can charge and use respawn anchors.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool respawnAnchorWorks = false;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether the dimension has skylight access or not.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool hasSkylight = true;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether players can use a bed to sleep.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool bedWorks = true;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// unknown
|
|
|
|
|
|
/// Values: "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" or something else.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly string effects = "minecraft:overworld";
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether players with the Bad Omen effect can cause a raid.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool hasRaids = true;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The minimum Y level.
|
|
|
|
|
|
/// </summary>
|
2022-07-24 21:48:09 +08:00
|
|
|
|
public readonly int minY = 0;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
/// The maximum Y level.
|
2022-07-24 21:41:56 +08:00
|
|
|
|
/// </summary>
|
2022-07-24 21:48:09 +08:00
|
|
|
|
public readonly int maxY = 256;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The maximum height.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public readonly int height = 256;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The maximum height to which chorus fruits and nether portals can bring players within this dimension.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly int logicalHeight = 256;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The multiplier applied to coordinates when traveling to the dimension.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly double coordinateScale = 1.0;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also causes lava to spread thinner.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool ultrawarm = false;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether the dimension has a bedrock ceiling or not. When true, causes lava to spread faster.
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
public readonly bool hasCeiling = false;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
2022-08-18 20:58:49 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Default value used in version below 1.17
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Dimension()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Name = "minecraft:overworld";
|
|
|
|
|
|
}
|
2022-07-24 21:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create from the "Dimension Codec" NBT Tag Compound
|
|
|
|
|
|
/// </summary>
|
2022-08-18 20:58:49 +02:00
|
|
|
|
/// <param name="name">Dimension name</param>
|
|
|
|
|
|
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
|
2022-07-24 21:41:56 +08:00
|
|
|
|
public Dimension(string name, Dictionary<string, object> nbt)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (name == null)
|
|
|
|
|
|
throw new ArgumentNullException("name");
|
|
|
|
|
|
if (nbt == null)
|
|
|
|
|
|
throw new ArgumentNullException("nbt Data");
|
|
|
|
|
|
|
|
|
|
|
|
this.Name = name;
|
|
|
|
|
|
|
|
|
|
|
|
if (nbt.ContainsKey("piglin_safe"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.piglinSafe = 1 == (byte)nbt["piglin_safe"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("natural"))
|
|
|
|
|
|
this.natural = 1 == (byte)nbt["natural"];
|
|
|
|
|
|
if (nbt.ContainsKey("ambient_light"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.ambientLight = (float)nbt["ambient_light"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("fixed_time"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.fixedTime = (long)nbt["fixed_time"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("infiniburn"))
|
|
|
|
|
|
this.infiniburn = (string)nbt["infiniburn"];
|
|
|
|
|
|
if (nbt.ContainsKey("respawn_anchor_works"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.respawnAnchorWorks = 1 == (byte)nbt["respawn_anchor_works"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("has_skylight"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.hasSkylight = 1 == (byte)nbt["has_skylight"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("bed_works"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.bedWorks = 1 == (byte)nbt["bed_works"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("effects"))
|
|
|
|
|
|
this.effects = (string)nbt["effects"];
|
|
|
|
|
|
if (nbt.ContainsKey("has_raids"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.hasRaids = 1 == (byte)nbt["has_raids"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("min_y"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.minY = (int)nbt["min_y"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("height"))
|
|
|
|
|
|
this.height = (int)nbt["height"];
|
|
|
|
|
|
if (nbt.ContainsKey("min_y") && nbt.ContainsKey("height"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.maxY = this.minY + this.height;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("logical_height"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.logicalHeight = (int)nbt["logical_height"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
if (nbt.ContainsKey("coordinate_scale"))
|
|
|
|
|
|
{
|
2022-07-24 22:03:02 +08:00
|
|
|
|
var coordinateScaleObj = nbt["coordinate_scale"];
|
|
|
|
|
|
if (coordinateScaleObj.GetType() == typeof(float))
|
|
|
|
|
|
this.coordinateScale = (float)coordinateScaleObj;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
else
|
2022-07-24 22:03:02 +08:00
|
|
|
|
this.coordinateScale = (double)coordinateScaleObj;
|
2022-07-24 21:41:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (nbt.ContainsKey("ultrawarm"))
|
|
|
|
|
|
this.ultrawarm = 1 == (byte)nbt["ultrawarm"];
|
|
|
|
|
|
if (nbt.ContainsKey("has_ceiling"))
|
2022-07-24 21:48:09 +08:00
|
|
|
|
this.hasCeiling = 1 == (byte)nbt["has_ceiling"];
|
2022-07-24 21:41:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|