Esempio n. 1
0
 public void SetBlock(int x, int y, int z, Block block)
 {
     if (InRange(x) && InRange(y) && InRange(z))
     {
         blocks.Set(block, x, y, z);
     }
     else
     {
         world.SetBlock(pos.x + x, pos.y + y, pos.z + z, block);
     }
 }
Esempio n. 2
0
		public virtual void TestSet()
		{
			BlockList<string> list = new BlockList<string>(4);
			try
			{
				list.Set(-1, "foo");
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual((-1).ToString(), badIndex.Message);
			}
			try
			{
				list.Set(0, "foo");
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(0.ToString(), badIndex.Message);
			}
			try
			{
				list.Set(4, "foo");
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(4.ToString(), badIndex.Message);
			}
			string fooStr = "foo";
			string barStr = "bar";
			string foobarStr = "foobar";
			list.AddItem(fooStr);
			list.AddItem(barStr);
			list.AddItem(foobarStr);
			NUnit.Framework.Assert.AreSame(fooStr, list[0]);
			NUnit.Framework.Assert.AreSame(barStr, list[1]);
			NUnit.Framework.Assert.AreSame(foobarStr, list[2]);
			NUnit.Framework.Assert.AreSame(fooStr, list.Set(0, barStr));
			NUnit.Framework.Assert.AreSame(barStr, list.Set(1, fooStr));
			NUnit.Framework.Assert.AreSame(barStr, list[0]);
			NUnit.Framework.Assert.AreSame(fooStr, list[1]);
			try
			{
				list.Set(3, "bar");
			}
			catch (IndexOutOfRangeException badIndex)
			{
				NUnit.Framework.Assert.AreEqual(3.ToString(), badIndex.Message);
			}
		}