Beispiel #1
0
		CopyState RotateX(CopyState state) {
			CopyState newState = new CopyState(state.X, state.Y, state.Z,
			                                   state.Width, state.Length, state.Height);
			byte[] blocks = state.Blocks, extBlocks = state.ExtBlocks;
			int newMaxY = newState.Height - 1;
			
			for (int i = 0; i < blocks.Length; i++) {
				ushort x, y, z;
				state.GetCoords(i, out x, out y, out z);
				newState.Set(x, newMaxY - z, y, blocks[i], extBlocks[i]);
			}
			newState.SetOrigin(state.OriginX, state.OriginY, state.OriginZ);
			return newState;
		}
Beispiel #2
0
		void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
			RevertAndClearState(p, x, y, z);
			CatchPos cpos = (CatchPos)p.blockchangeObject;
			ushort minX = (ushort)Math.Min(x, cpos.x), minY = (ushort)Math.Min(y, cpos.y);
			ushort minZ = (ushort)Math.Min(z, cpos.z), maxX = (ushort)Math.Max(x, cpos.x);
			ushort maxY = (ushort)Math.Max(y, cpos.y), maxZ = (ushort)Math.Max(z, cpos.z);
			
			CopyState state = new CopyState(minX, minY, minZ, maxX - minX + 1, 
			                                maxY - minY + 1, maxZ - minZ + 1);
			state.SetOrigin(cpos.x, cpos.y, cpos.z);
			int totalAir = 0, index = 0;
			p.copyAir = cpos.type == 2;
			
			for (ushort yy = minY; yy <= maxY; ++yy)
				for (ushort zz = minZ; zz <= maxZ; ++zz)
					for (ushort xx = minX; xx <= maxX; ++xx)
			{
				byte b = p.level.GetTile(xx, yy, zz);
				if (!Block.canPlace(p, b)) { index++; continue; }
				
				if (b == Block.air && cpos.type != 2 || cpos.ignoreTypes.Contains(b))
					totalAir++;
				if (!cpos.ignoreTypes.Contains(b)) {
					state.Blocks[index] = b;
					if (b == Block.custom_block)
						state.ExtBlocks[index] = p.level.GetExtTile(xx, yy, zz);
				}
				index++;
			}
			p.CopyBuffer = state;

			if ((state.Volume - totalAir) > p.group.maxBlocks) {
				Player.SendMessage(p, "You tried to copy " + state.Volume + " blocks.");
				Player.SendMessage(p, "You cannot copy more than " + p.group.maxBlocks + ".");
				p.CopyBuffer = null;
				return;
			}

			if (cpos.type == 1)
				for (ushort yy = minY; yy <= maxY; ++yy)
					for (ushort zz = minZ; zz <= maxZ; ++zz)
						for (ushort xx = minX; xx <= maxX; ++xx)
			{
				byte b = p.level.GetTile(xx, yy, zz);
				if (b != Block.air && Block.canPlace(p, b))
					p.level.Blockchange(p, xx, yy, zz, Block.air);
			}

			Player.SendMessage(p, (state.Volume - totalAir) + " blocks copied.");
			if (allowoffset != -1) {
				Player.SendMessage(p, "Place a block to determine where to paste from");
				p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3);
			}
		}