本文整理汇总了C#中NbtCompound.Get方法的典型用法代码示例。如果您正苦于以下问题:C# NbtCompound.Get方法的具体用法?C# NbtCompound.Get怎么用?C# NbtCompound.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NbtCompound
的用法示例。
在下文中一共展示了NbtCompound.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TileEntity
/// <summary>
/// Load a TileEntity's basic values (call via base() in all inheriting files)
/// </summary>
/// <param name="CX">Chunk X Coordinate</param>
/// <param name="CY">Chunk Y Coordinate</param>
/// <param name="CS">Chunk horizontal scale</param>
/// <param name="c">TileEntity's NbtCompound.</param>
public TileEntity(int CX,int CY,int CS,NbtCompound c)
{
Pos = new Vector3i(
c.Get<NbtInt>("x").Value,
c.Get<NbtInt>("y").Value,
c.Get<NbtInt>("z").Value);
ID = (c["id"] as NbtString).Value;
orig = c;
}
示例2: TileEntity
/// <summary>
/// Load a TileEntity's basic values (call via base() in all inheriting files)
/// </summary>
/// <param name="c"></param>
public TileEntity(NbtCompound c)
{
orig = c;
Pos = new Vector3i(
c.Get<NbtInt>("x").Value,
c.Get<NbtInt>("z").Value,
c.Get<NbtInt>("y").Value);
id = c.Get<NbtString>("id").Value;
}
示例3: Area
public Area(NbtCompound cmpd)
{
name = cmpd.Get<NbtString>("name").Value;
NbtList ground = cmpd.Get<NbtList>("ground");
foreach(NbtCompound alpha in ground) {
int x = alpha.Get<NbtByte>("x").Value;
int y = alpha.Get<NbtByte>("y").Value;
platformMap.Add(new Point(x, y));
}
Map.portalsToProcess[this] = cmpd.Get<NbtList>("portal").ToArray<NbtCompound>().ToList<NbtCompound>();
}
示例4: Area
public Area(NbtCompound cmpd)
{
name = cmpd.Get<NbtString>("name").Value;
NbtList ground = cmpd.Get<NbtList>("ground");
foreach(NbtCompound alpha in ground) {
int x = alpha.Get<NbtByte>("x").Value;
int y = alpha.Get<NbtByte>("y").Value;
map.Add(new Point(x, y), new Platform(x, y, this));
}
NbtList portal = cmpd.Get<NbtList>("portal");
foreach(NbtCompound alpha in portal) {
int x = alpha.Get<NbtByte>("x").Value;
int y = alpha.Get<NbtByte>("y").Value;
map.Add(new Point(x, y), new Portal(x, y, this));
Portal.portalsToProcess.Add(new Portal(x, y, this), alpha);
}
}
示例5: FromNbt
public static TileEntity FromNbt(NbtCompound entityTag, out Vector3 position)
{
position = Vector3.Zero;
var id = entityTag.Get<NbtString>("id").Value;
Type type = (from e in dummyInstances where e.Id == id select e.GetType()).FirstOrDefault();
if (type == null)
return null;
var serializer = new NbtSerializer(type);
var entity = (TileEntity)serializer.Deserialize(entityTag);
position = new Vector3(
entityTag.Get<NbtInt>("x").Value,
entityTag.Get<NbtInt>("y").Value,
entityTag.Get<NbtInt>("z").Value);
return entity;
}
示例6: Read
public NbtCompound Read(NbtCompound metadata)
{
var Data = metadata.Get<NbtCompound>("MCForge");
Logger.Log(Data["perbuild"].ToString());
if (Data != null)
{
perbuild = Data["perbuild"].ByteValue;
pervisit = Data["pervisit"].ByteValue;
metadata.Remove(Data);
}
return metadata;
}
示例7: Read
public NbtCompound Read(NbtCompound Metadata)
{
NbtCompound CPEData = Metadata.Get<NbtCompound>("CPE");
if (CPEData != null)
{
if (CPEData["ClickDistance"] != null)
{
ClickDistanceVersion = CPEData["ClickDistance"]["ExtensionVersion"].IntValue;
ClickDistance = CPEData["ClickDistance"]["Distance"].ShortValue;
}
if (CPEData["CustomBlocks"] != null)
{
CustomBlocksVersion = CPEData["CustomBlocks"]["ExtensionVersion"].IntValue;
CustomBlocksLevel = CPEData["CustomBlocks"]["SupportLevel"].ShortValue;
CustomBlocksFallback = CPEData["CustomBlocks"]["Fallback"].ByteArrayValue;
}
if (CPEData["EnvColors"] != null)
{
EnvColorsVersion = CPEData["EnvColors"]["ExtensionVersion"].IntValue;
SkyColor = new short[] { CPEData["EnvColors"]["Sky"]["R"].ShortValue, CPEData["EnvColors"]["Sky"]["G"].ShortValue, CPEData["EnvColors"]["Sky"]["B"].ShortValue };
CloudColor = new short[] { CPEData["EnvColors"]["Cloud"]["R"].ShortValue, CPEData["EnvColors"]["Cloud"]["G"].ShortValue, CPEData["EnvColors"]["Cloud"]["B"].ShortValue };
FogColor = new short[] { CPEData["EnvColors"]["Fog"]["R"].ShortValue, CPEData["EnvColors"]["Fog"]["G"].ShortValue, CPEData["EnvColors"]["Fog"]["B"].ShortValue };
AmbientColor = new short[] { CPEData["EnvColors"]["Ambient"]["R"].ShortValue, CPEData["EnvColors"]["Ambient"]["G"].ShortValue, CPEData["EnvColors"]["Ambient"]["B"].ShortValue };
SunlightColor = new short[] { CPEData["EnvColors"]["Sunlight"]["R"].ShortValue, CPEData["EnvColors"]["Sunlight"]["R"].ShortValue, CPEData["EnvColors"]["Sunlight"]["R"].ShortValue };
}
if (CPEData["EnvMapAppearance"] != null)
{
EnvMapAppearanceVersion = CPEData["EnvMapAppearance"]["ExtensionVersion"].IntValue;
TextureURL = CPEData["EnvMapAppearance"]["TextureURL"].StringValue;
SideBlock = CPEData["EnvMapAppearance"]["SideBlock"].ByteValue;
EdgeBlock = CPEData["EnvMapAppearance"]["EdgeBlock"].ByteValue;
SideLevel = CPEData["EnvMapAppearance"]["SideLevel"].ShortValue;
}
Metadata.Remove(CPEData);
}
return Metadata;
}
示例8: FromNbt
public static Slot FromNbt(NbtCompound compound)
{
var s = Slot.EmptySlot;
s.Id = compound.Get<NbtShort>("id").Value;
s.Metadata = compound.Get<NbtShort>("Damage").Value;
s.Count = (sbyte)compound.Get<NbtByte>("Count").Value;
s.Index = compound.Get<NbtByte>("Slot").Value;
if (compound.Get<NbtCompound>("tag") != null)
{
s.Nbt = new NbtFile();
s.Nbt.RootTag = compound.Get<NbtCompound>("tag");
}
return s;
}
示例9: Read
public NbtCompound Read(NbtCompound metadata) {
var cpeData = metadata.Get<NbtCompound>("CPE");
if (cpeData == null)
return metadata;
if (cpeData["ClickDistance"] != null) {
ClickDistanceVersion = cpeData["ClickDistance"]["ExtensionVersion"].IntValue;
ClickDistance = cpeData["ClickDistance"]["Distance"].ShortValue;
}
if (cpeData["CustomBlocks"] != null) {
CustomBlocksVersion = cpeData["CustomBlocks"]["ExtensionVersion"].IntValue;
CustomBlocksLevel = cpeData["CustomBlocks"]["SupportLevel"].ShortValue;
CustomBlocksFallback = cpeData["CustomBlocks"]["Fallback"].ByteArrayValue;
}
if (cpeData["EnvColors"] != null) {
EnvColorsVersion = cpeData["EnvColors"]["ExtensionVersion"].IntValue;
SkyColor = new[] { cpeData["EnvColors"]["Sky"]["R"].ShortValue, cpeData["EnvColors"]["Sky"]["G"].ShortValue, cpeData["EnvColors"]["Sky"]["B"].ShortValue };
CloudColor = new[] { cpeData["EnvColors"]["Cloud"]["R"].ShortValue, cpeData["EnvColors"]["Cloud"]["G"].ShortValue, cpeData["EnvColors"]["Cloud"]["B"].ShortValue };
FogColor = new[] { cpeData["EnvColors"]["Fog"]["R"].ShortValue, cpeData["EnvColors"]["Fog"]["G"].ShortValue, cpeData["EnvColors"]["Fog"]["B"].ShortValue };
AmbientColor = new[] { cpeData["EnvColors"]["Ambient"]["R"].ShortValue, cpeData["EnvColors"]["Ambient"]["G"].ShortValue, cpeData["EnvColors"]["Ambient"]["B"].ShortValue };
SunlightColor = new[] { cpeData["EnvColors"]["Sunlight"]["R"].ShortValue, cpeData["EnvColors"]["Sunlight"]["R"].ShortValue, cpeData["EnvColors"]["Sunlight"]["R"].ShortValue };
}
if (cpeData["EnvMapAppearance"] != null) {
EnvMapAppearanceVersion = cpeData["EnvMapAppearance"]["ExtensionVersion"].IntValue;
TextureUrl = cpeData["EnvMapAppearance"]["TextureURL"].StringValue;
SideBlock = cpeData["EnvMapAppearance"]["SideBlock"].ByteValue;
EdgeBlock = cpeData["EnvMapAppearance"]["EdgeBlock"].ByteValue;
SideLevel = cpeData["EnvMapAppearance"]["SideLevel"].ShortValue;
}
if (cpeData["EnvWeatherType"] != null)
Weather = cpeData["EnvWeatherType"]["WeatherType"].ByteValue;
metadata.Remove(cpeData);
return metadata;
}
示例10: Read
public NbtCompound Read(NbtCompound metadata)
{
var hcData = metadata.Get<NbtCompound>("Hypercube");
if (hcData == null)
return metadata;
BuildPerms = hcData["BuildPerms"].StringValue;
ShowPerms = hcData["ShowPerms"].StringValue;
JoinPerms = hcData["JoinPerms"].StringValue;
Physics = Convert.ToBoolean(hcData["Physics"].ByteValue);
Building = Convert.ToBoolean(hcData["Building"].ByteValue);
History = Convert.ToBoolean(hcData["History"].ByteValue);
SaveInterval = hcData["SaveInterval"].IntValue;
if (hcData["MOTD"] != null)
Motd = hcData["MOTD"].StringValue;
metadata.Remove(hcData);
return metadata;
}
示例11: Slime
public Slime(NbtCompound c)
: base(c)
{
Size = c.Get<NbtInt>("Size").Value;
}
示例12: FromNbt
public static Slot FromNbt(NbtCompound compound)
{
var s = new Slot();
s.Id = (ushort)compound.Get<NbtShort>("id").Value;
s.Metadata = (ushort)compound.Get<NbtShort>("Damage").Value;
s.Count = compound.Get<NbtByte>("Count").Value;
s.Index = compound.Get<NbtByte>("Slot").Value;
return s;
}
示例13: GetEntity
/// <summary>
/// Load a TileEntity from an NbtCompound.
/// </summary>
/// <param name="CX">Chunk X Coordinate.</param>
/// <param name="CY">Chunk Y Coordinate.</param>
/// <param name="CS">Chunk horizontal scale (16 in /game/)</param>
/// <param name="c"></param>
/// <returns>TileEntity.</returns>
public static TileEntity GetEntity(int CX, int CY, int CS, NbtCompound c)
{
string entID = c.Get<NbtString>("id").Value;
if (TileEntityTypes.ContainsKey(entID))
return (TileEntity)TileEntityTypes[entID].GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(NbtCompound) }).Invoke(new Object[] { CX,CY,CS,c });
// Try to figure out what the hell this is.
if (!Directory.Exists("TileEntities"))
Directory.CreateDirectory("TileEntities");
GenTemplate(c, "tileentity.template");
return new TileEntity(c);
}
示例14: GenTemplate
// This tosses together a cheapass entity class for faster updates.
// Primarily because I'm a lazy fuck.
private static void GenTemplate(NbtCompound c, string tpl)
{
string ID = c.Get<NbtString>("id").Value;
string Name = ID.Substring(0, 1).ToUpper() + ID.Substring(1);
string newthing = File.ReadAllText("TileEntities/"+tpl);
// Construct variables
string vardec = "";
string dectmpl = "\n\t\t[Category(\"{0}\"), Description(\"(WIP)\")]\n\t\tpublic {1} {2} {{get;set;}}\n";
string varassn = "";
string assntpl = "\n\t\t\t{0} = c.Get<{1}>(\"{2}\").Value;";
string nbtassn = "";
string nbttpl = "\n\t\t\tc.Add(new {0}(\"{1}\", {2}));";
// Figure out if there are any new fields that we should be concerned about...
foreach (NbtTag t in c)
{
if (CommonTileEntityVars.Contains(t.Name))
continue;
string vname = t.Name.Substring(0, 1).ToUpper() + t.Name.Substring(1);
string tagname = t.Name;
string type = GetNativeType(t);
string nbtTag = t.GetType().Name;
vardec += string.Format(dectmpl, Name, type, vname);
varassn += string.Format(assntpl, vname, nbtTag, tagname);
nbtassn += string.Format(nbttpl, nbtTag, tagname, vname);
}
// {DATA_DUMP} - Crap out a dump of the entity.
// {ENTITY_NAME} - Entity name, but capitalized (CamelCase)
// {NEW_VARS} - New var declarations.
// {VAR_ASSIGNMENT} - Set the vars from the Compound.
// {TO_NBT} - Set the appropriate stuff in the Compound.
// {ENTITY_ID} - Raw entity ID
newthing = newthing.Replace("{DATA_DUMP}", c.ToString());
newthing = newthing.Replace("{TILEENTITY_NAME}", Name);
newthing = newthing.Replace("{TILEENTITY_ID}", ID);
newthing = newthing.Replace("{VAR_DECL}", vardec);
newthing = newthing.Replace("{VAR_ASSIGNMENT}", varassn);
newthing = newthing.Replace("{TO_NBT}", nbtassn);
File.WriteAllText("TileEntities/" + Name + ".cs", newthing);
// TODO: Compile?
}
示例15: SetBaseStuff
internal void SetBaseStuff(NbtCompound c)
{
FallDistance = (c["FallDistance"] as NbtFloat).Value;
Motion = new Vector3d(c["Motion"] as NbtList,false);
Pos = new Vector3d(c["Pos"] as NbtList,false);
OnGround = c.Get<NbtByte>("OnGround").Value;
Rotation = Rotation.FromNbt(c.Get<NbtList>("Rotation"));
//Console.WriteLine("Loaded entity {0} @ {1}", (c["id"] as NbtString).Value, Pos);
}