本文整理汇总了C#中Level.IntToBlockPos方法的典型用法代码示例。如果您正苦于以下问题:C# Level.IntToBlockPos方法的具体用法?C# Level.IntToBlockPos怎么用?C# Level.IntToBlockPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.IntToBlockPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Physics
public override void Physics(Level level, int pos)
{
BlockPos blockPos = level.IntToBlockPos(pos);
BlockPos belowBlockPos = blockPos.Diff(0, -1, 0);
if (!level.Physics.OtherData.ContainsKey(pos)) return;
var current = (byte)(level.Physics.OtherData[pos] - 1);
if (current == 0) return;
int belowPos = level.PosToInt(belowBlockPos);
byte type = level.BlockData[belowPos];
if (type == (byte)MCBlocks.LavaStill)
{
if (level.Physics.OtherData[belowPos] < current)
{
level.Physics.OtherData.Remove(belowPos);
level.Physics.OtherData.Add(belowPos, current);
}
}
else if (Crushable.Contains(type))
{
level.Physics.OtherData.Remove(belowPos);
level.Physics.OtherData.Add(belowPos, current);
level.PhysicsBlockChange(belowBlockPos, MCBlocks.LavaStill);
}
else
{
for (int x = -1; x < 2; ++x)
for (int z = -1; z < 2; ++z)
{
if (Math.Abs(x) == 1 && Math.Abs(z) == 1) continue;
if (blockPos.X + x < 0 || blockPos.Z + z < 0) continue;
BlockPos aroundPos = blockPos.Diff(x, 0, z);
if (level.NotInBounds(aroundPos)) continue;
int newPos = level.PosToInt(aroundPos);
byte newType = level.BlockData[newPos];
if (newType == (byte)MCBlocks.LavaStill)
{
if (level.Physics.OtherData.ContainsKey(newPos))
{
if (level.Physics.OtherData[newPos] >= current) continue;
level.Physics.OtherData[newPos] = current;
}
else
{
level.Physics.OtherData.Add(newPos, current);
}
}
else if (Crushable.Contains(newType))
{
level.Physics.OtherData.Remove(newPos);
level.Physics.OtherData.Add(newPos, current);
level.PhysicsBlockChange(aroundPos, MCBlocks.LavaStill);
//if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
//level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
return;
}
}
}
}